Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lead, LAG & CTE Victor Ivantsov.

Similar presentations


Presentation on theme: "Lead, LAG & CTE Victor Ivantsov."— Presentation transcript:

1 Lead, LAG & CTE Victor Ivantsov

2 About VICTOR IVANTSOV Started with SQL Server 6.5 in 1996, still enjoy it Now on SQL 2016 Standard, SSIS, SSRS, T-SQL My Toastmaster club (Rivercity TM) meets every 7:15 AM Enjoy running, soccer, music (voice, text)

3 Agenda Introduction: why I am addicted to cross/outer apply Deep dive #1: split string values into rows by delimiter Deep dive #2: support any user defined filter condition Adjournment, QnA

4 Big RecordsETS @dir @sort @total @limit @start

5 @sort As Column Expression

6 ORDER BY CLAUSE

7 SPLIT LEFT and RIGHT Values
‘Jacksonville, FL 33296’ ‘Smith Jr, Michael Peter’ ‘coverageAmount ( 7,500’ ‘UploadFile_usrid_12345.xls’ ‘3)’

8 Ugly & Buggy code

9 Reuse existing code Take existing function that split string values via XML Add item # to the list Escape special xml characters (&, <, > “) Use new LEAD sql keword

10 Split values via xml - Preparation

11 SPLIT VALUES – XML Ready

12 Split Values – Function Ready

13 LEAD – usage example

14 Another complex function

15 Supported EXPRESSions
Is_match = New computed column

16 LEFT OUTER JOIN SAME COMPLEX FUNCTION?
SOLUTION #1 LEFT OUTER JOIN SAME COMPLEX FUNCTION? TOO MUCH COMPLEXITY FOR QUERY OPTIMIZER

17 MULTI STATEMENT FUNCTION
SOLUTION #2 MULTI STATEMENT FUNCTION STILL TOO SLOW

18 LaG & CTE *

19 Q & A Victor Ivantsov (voice, text) Rivercity Toastmasters, club #892 meets every 7:15 AM IHOP 3250 Hodges Blvd, Jacksonville, FL 32224


Download ppt "Lead, LAG & CTE Victor Ivantsov."

Similar presentations


Ads by Google