17
Fast and Furious: Discovering Windowing Function Ahias Portillo [email protected] MVP, MCITP en Sql Server DPA, SolidQ

Fast and Furious: Discovering Windowing Function

Embed Size (px)

Citation preview

Page 1: Fast and Furious: Discovering Windowing Function

Fast and Furious: Discovering Windowing FunctionAhias [email protected], MCITP en Sql ServerDPA, SolidQ

Page 3: Fast and Furious: Discovering Windowing Function

What they can do WF?

Page 4: Fast and Furious: Discovering Windowing Function

What we DO?

Page 5: Fast and Furious: Discovering Windowing Function

We do things must not do

Page 6: Fast and Furious: Discovering Windowing Function

Window Functions

(Fabiano Amorim, Window Functions in Sql Server)

Page 7: Fast and Furious: Discovering Windowing Function

What can I do?

Paging De-duplicating data Returning top n rows

per group Computing running

totals

Identifying gaps and islands

Computing percentiles

Computing the mode of the distribution

You can imagine….

Page 8: Fast and Furious: Discovering Windowing Function

OVER

Page 9: Fast and Furious: Discovering Windowing Function

Aggregate Function

AVG CHECKSUM_AGG COUNT COUNT_BIG

MAX MIN SUM VAR VARP

Page 10: Fast and Furious: Discovering Windowing Function

DEMO

Page 11: Fast and Furious: Discovering Windowing Function

Ranking Functions

ROW_NUMBER RANK DENSE_RANK NTILE

Page 12: Fast and Furious: Discovering Windowing Function

DEMO

Page 13: Fast and Furious: Discovering Windowing Function

Offset Functions

LAG() LEAD() LAST_VALUE() FIRST_VALUE()

Page 14: Fast and Furious: Discovering Windowing Function

DEMO

Page 15: Fast and Furious: Discovering Windowing Function

Distribution Functions

CUME_DIST() PERCENT_RANK() PERCENTILE_CONT() PERCENTILE_DISC()

Page 16: Fast and Furious: Discovering Windowing Function

DEMO

Page 17: Fast and Furious: Discovering Windowing Function

Q & A

?