SlideShare a Scribd company logo
Dinesh Karunarathna
B.Sc. (Eng.),MCTS – SQL Server
Senior DBA – Pearson Lanka
dineshk@ecollege.com
http://www.dbbitsandpieces.blogspot.com/
Introduction
What are the windowing functions
Functions that operates/ manipulates on set of rows
Types of windowing functions
Ranking functions - Returns a ranking value for each row
Aggregate functions - Performs calculations on set of values
Analytic functions - Compute moving averages, running
totals, percentages…
Improvements of windowing functions in SQL Server
2012
New functionality in SQL Server
2005
OVER() Clause – Used to define a window or user
specified set of rows within a query result set
PARTITION BY Clause - Divides the query result set into
partitions
Ranking functions
Changes in aggregate functions
Partitioning a data set
Partitioned by LocationID Partitioned by CustomerID
Ranking functions
ROW_NUMBER() - Sequential number of a row within
a partition of a result set
RANK() - Rank of each row within the partition
DENSE_RANK() - rank of rows within the partition of a
result set, without any gaps in the ranking
NTILE() - Distributes the rows in an ordered partition
into a specified number of groups
Demo…
Aggregate functions
AVG()
SUM()
MIN()
MAX()
COUNT()….
Aggregate functions cont…
Enhancements in SQL Serve 2005
SUM(Column1) OVER (PARTITION BY Column2)
Enhancements in SQL Server 2012
SUM(Column1) OVER (PARTITION BY Column2
ORDER BY Column3)
Demo…
New features with SQL Server 2012
Analytic functions
FIRST_VALUE()
LAST_VALUE()
LEAD()
LAG()
PERCENT_RANK()
PERCENTILE_COUNT()
PERCENTILE_DISC()
CUME_DIST()
New features with SQL Server 2012
cont …
Enhancements of Aggregate functions
ODER BY with OVER() clause
Enhancements of defining the partition (window)
ROWS/RANGE
CURRENT ROW
PRECEDING
FOLLOWING
UNBOUNDED
Demo …
Q & A
Which function can be best used to retrieve daily
increment?
List five new key words used to define a window of a
dataset
Thank you.

More Related Content

What's hot

Uml Diagrams
Uml DiagramsUml Diagrams
UML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptxUML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptx
Nwabueze Obioma
 
Component Diagram
Component DiagramComponent Diagram
Component Diagram
Ahmed Yousef
 
Enhancement of Action Description Language for UML Activity Diagram Review
Enhancement of Action Description Language for UML Activity Diagram ReviewEnhancement of Action Description Language for UML Activity Diagram Review
Enhancement of Action Description Language for UML Activity Diagram Review
Chinnapat Kaewchinporn
 
Activity diag
Activity diagActivity diag
Activity diag
Preeti Mishra
 
Object Oriented Analysis & Design
Object Oriented Analysis & DesignObject Oriented Analysis & Design
Object Oriented Analysis & Design
kpthakershy
 
Introduction to the Unified Modeling Language (UML)
Introduction to the Unified Modeling Language (UML)Introduction to the Unified Modeling Language (UML)
Introduction to the Unified Modeling Language (UML)
Marwa Ali Eissa
 
Dynamic modeling
Dynamic modelingDynamic modeling
Dynamic modeling
Preeti Mishra
 
Uml
UmlUml
Oracle Demantra Training
 Oracle Demantra Training Oracle Demantra Training
Oracle Demantra Training
williamflender
 
14 functional design
14 functional design14 functional design
14 functional designrandhirlpu
 
UNIFIED MODELING LANGUAGE
UNIFIED MODELING LANGUAGEUNIFIED MODELING LANGUAGE
UNIFIED MODELING LANGUAGE
Raval Chirag
 

What's hot (13)

Uml Diagrams
Uml DiagramsUml Diagrams
Uml Diagrams
 
UML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptxUML and Software Modeling Tools.pptx
UML and Software Modeling Tools.pptx
 
Component Diagram
Component DiagramComponent Diagram
Component Diagram
 
Enhancement of Action Description Language for UML Activity Diagram Review
Enhancement of Action Description Language for UML Activity Diagram ReviewEnhancement of Action Description Language for UML Activity Diagram Review
Enhancement of Action Description Language for UML Activity Diagram Review
 
Activity diag
Activity diagActivity diag
Activity diag
 
Uml2
Uml2Uml2
Uml2
 
Object Oriented Analysis & Design
Object Oriented Analysis & DesignObject Oriented Analysis & Design
Object Oriented Analysis & Design
 
Introduction to the Unified Modeling Language (UML)
Introduction to the Unified Modeling Language (UML)Introduction to the Unified Modeling Language (UML)
Introduction to the Unified Modeling Language (UML)
 
Dynamic modeling
Dynamic modelingDynamic modeling
Dynamic modeling
 
Uml
UmlUml
Uml
 
Oracle Demantra Training
 Oracle Demantra Training Oracle Demantra Training
Oracle Demantra Training
 
14 functional design
14 functional design14 functional design
14 functional design
 
UNIFIED MODELING LANGUAGE
UNIFIED MODELING LANGUAGEUNIFIED MODELING LANGUAGE
UNIFIED MODELING LANGUAGE
 

Similar to Windowing Functions in SQL Server

Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012Ziaur Rahman
 
Fix My Functions: TSQL User Defined Functions in SQL Server
Fix My Functions: TSQL User Defined Functions in SQL ServerFix My Functions: TSQL User Defined Functions in SQL Server
Fix My Functions: TSQL User Defined Functions in SQL Server
Kendra Little
 
Analytic & Windowing functions in oracle
Analytic & Windowing functions in oracleAnalytic & Windowing functions in oracle
Analytic & Windowing functions in oracle
Logan Palanisamy
 
Practical SQL query monitoring and optimization
Practical SQL query monitoring and optimizationPractical SQL query monitoring and optimization
Practical SQL query monitoring and optimization
Ivo Andreev
 
Veri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL DesteğiVeri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL Desteği
Emrah METE
 
Analysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxAnalysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptx
Brendan Furey
 
Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000webhostingguy
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
Eduardo Castro
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
BhupendraShahi6
 
Daniel Bowlin Portfolio Rev1
Daniel Bowlin Portfolio Rev1Daniel Bowlin Portfolio Rev1
Daniel Bowlin Portfolio Rev1DanielWBowlin
 
Adv.+SQL+PPT+final.pptx
Adv.+SQL+PPT+final.pptxAdv.+SQL+PPT+final.pptx
Adv.+SQL+PPT+final.pptx
AmitDas125851
 
Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
Dhananjay Goel
 
Sql and its functions
Sql and its functionsSql and its functions
Sql and its functions
Rohit Kumar
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SabrinaShanta2
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
Chhom Karath
 
Web Cloud Computing SQL Server - Ferrara University
Web Cloud Computing SQL Server  -  Ferrara UniversityWeb Cloud Computing SQL Server  -  Ferrara University
Web Cloud Computing SQL Server - Ferrara University
antimo musone
 
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
Jürgen Ambrosi
 
Oracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangaloreOracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangalore
Suvash Chowdary
 
Oracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangaloreOracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangalore
Suvash Chowdary
 

Similar to Windowing Functions in SQL Server (20)

Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012Developers' New features of Sql server express 2012
Developers' New features of Sql server express 2012
 
Fix My Functions: TSQL User Defined Functions in SQL Server
Fix My Functions: TSQL User Defined Functions in SQL ServerFix My Functions: TSQL User Defined Functions in SQL Server
Fix My Functions: TSQL User Defined Functions in SQL Server
 
Analytic & Windowing functions in oracle
Analytic & Windowing functions in oracleAnalytic & Windowing functions in oracle
Analytic & Windowing functions in oracle
 
Practical SQL query monitoring and optimization
Practical SQL query monitoring and optimizationPractical SQL query monitoring and optimization
Practical SQL query monitoring and optimization
 
Veri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL DesteğiVeri Ambarları için Oracle'ın Analitik SQL Desteği
Veri Ambarları için Oracle'ın Analitik SQL Desteği
 
Analysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptxAnalysing Performance of Algorithmic SQL and PLSQL.pptx
Analysing Performance of Algorithmic SQL and PLSQL.pptx
 
Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000Application development using Microsoft SQL Server 2000
Application development using Microsoft SQL Server 2000
 
TSQL in SQL Server 2012
TSQL in SQL Server 2012TSQL in SQL Server 2012
TSQL in SQL Server 2012
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Daniel Bowlin Portfolio Rev1
Daniel Bowlin Portfolio Rev1Daniel Bowlin Portfolio Rev1
Daniel Bowlin Portfolio Rev1
 
Adv.+SQL+PPT+final.pptx
Adv.+SQL+PPT+final.pptxAdv.+SQL+PPT+final.pptx
Adv.+SQL+PPT+final.pptx
 
Oracle SQL Advanced
Oracle SQL AdvancedOracle SQL Advanced
Oracle SQL Advanced
 
Sql and its functions
Sql and its functionsSql and its functions
Sql and its functions
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
Web Cloud Computing SQL Server - Ferrara University
Web Cloud Computing SQL Server  -  Ferrara UniversityWeb Cloud Computing SQL Server  -  Ferrara University
Web Cloud Computing SQL Server - Ferrara University
 
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
 
Oracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangaloreOracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangalore
 
Oracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangaloreOracle 11g developer on linux training in bangalore
Oracle 11g developer on linux training in bangalore
 

More from SQL Server Sri Lanka User Group

Minding SQL Server Memory
Minding SQL Server MemoryMinding SQL Server Memory
Minding SQL Server Memory
SQL Server Sri Lanka User Group
 
Using Extended Events
Using Extended EventsUsing Extended Events
Using Extended Events
SQL Server Sri Lanka User Group
 
Breaking a Myth in 600 Seconds: Seek is Always Better than Scan
Breaking a Myth in 600 Seconds: Seek is Always Better than ScanBreaking a Myth in 600 Seconds: Seek is Always Better than Scan
Breaking a Myth in 600 Seconds: Seek is Always Better than Scan
SQL Server Sri Lanka User Group
 
Anything SQL: Lightning Talks
Anything SQL: Lightning TalksAnything SQL: Lightning Talks
Anything SQL: Lightning Talks
SQL Server Sri Lanka User Group
 
Whirlwind DBA Demos
Whirlwind DBA DemosWhirlwind DBA Demos
Whirlwind DBA Demos
SQL Server Sri Lanka User Group
 
Why OLAP? How OLAP.
Why OLAP? How OLAP.Why OLAP? How OLAP.
Why OLAP? How OLAP.
SQL Server Sri Lanka User Group
 
Using Resource Governor to Control Resource Utilization
Using Resource Governor to Control Resource UtilizationUsing Resource Governor to Control Resource Utilization
Using Resource Governor to Control Resource Utilization
SQL Server Sri Lanka User Group
 

More from SQL Server Sri Lanka User Group (7)

Minding SQL Server Memory
Minding SQL Server MemoryMinding SQL Server Memory
Minding SQL Server Memory
 
Using Extended Events
Using Extended EventsUsing Extended Events
Using Extended Events
 
Breaking a Myth in 600 Seconds: Seek is Always Better than Scan
Breaking a Myth in 600 Seconds: Seek is Always Better than ScanBreaking a Myth in 600 Seconds: Seek is Always Better than Scan
Breaking a Myth in 600 Seconds: Seek is Always Better than Scan
 
Anything SQL: Lightning Talks
Anything SQL: Lightning TalksAnything SQL: Lightning Talks
Anything SQL: Lightning Talks
 
Whirlwind DBA Demos
Whirlwind DBA DemosWhirlwind DBA Demos
Whirlwind DBA Demos
 
Why OLAP? How OLAP.
Why OLAP? How OLAP.Why OLAP? How OLAP.
Why OLAP? How OLAP.
 
Using Resource Governor to Control Resource Utilization
Using Resource Governor to Control Resource UtilizationUsing Resource Governor to Control Resource Utilization
Using Resource Governor to Control Resource Utilization
 

Recently uploaded

Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
haila53
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
James Polillo
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive data
theahmadsaood
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
correoyaya
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Linda486226
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Boston Institute of Analytics
 

Recently uploaded (20)

Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdfCh03-Managing the Object-Oriented Information Systems Project a.pdf
Ch03-Managing the Object-Oriented Information Systems Project a.pdf
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive data
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
 

Windowing Functions in SQL Server

  • 1. Dinesh Karunarathna B.Sc. (Eng.),MCTS – SQL Server Senior DBA – Pearson Lanka dineshk@ecollege.com http://www.dbbitsandpieces.blogspot.com/
  • 2. Introduction What are the windowing functions Functions that operates/ manipulates on set of rows Types of windowing functions Ranking functions - Returns a ranking value for each row Aggregate functions - Performs calculations on set of values Analytic functions - Compute moving averages, running totals, percentages… Improvements of windowing functions in SQL Server 2012
  • 3. New functionality in SQL Server 2005 OVER() Clause – Used to define a window or user specified set of rows within a query result set PARTITION BY Clause - Divides the query result set into partitions Ranking functions Changes in aggregate functions
  • 4. Partitioning a data set Partitioned by LocationID Partitioned by CustomerID
  • 5. Ranking functions ROW_NUMBER() - Sequential number of a row within a partition of a result set RANK() - Rank of each row within the partition DENSE_RANK() - rank of rows within the partition of a result set, without any gaps in the ranking NTILE() - Distributes the rows in an ordered partition into a specified number of groups
  • 8. Aggregate functions cont… Enhancements in SQL Serve 2005 SUM(Column1) OVER (PARTITION BY Column2) Enhancements in SQL Server 2012 SUM(Column1) OVER (PARTITION BY Column2 ORDER BY Column3)
  • 10. New features with SQL Server 2012 Analytic functions FIRST_VALUE() LAST_VALUE() LEAD() LAG() PERCENT_RANK() PERCENTILE_COUNT() PERCENTILE_DISC() CUME_DIST()
  • 11. New features with SQL Server 2012 cont … Enhancements of Aggregate functions ODER BY with OVER() clause Enhancements of defining the partition (window) ROWS/RANGE CURRENT ROW PRECEDING FOLLOWING UNBOUNDED
  • 13. Q & A Which function can be best used to retrieve daily increment? List five new key words used to define a window of a dataset