Wednesday, May 25, 2022

What's new in SQL Syntax in SQL Server 2022

 Found a neat article on new syntax in 2022 by Aaron Betrand



Most exciting one might be DATE_BUCKET, which may eliminate the need to roll your own magic dates to find things like first of this month, first of last month, five minute intervals, into one command.  One quote of a useful feature combining two new commands; "

BONUS

We can combine DATE_BUCKET and GENERATE_SERIES to build a contiguous series of date/time values. I often see people struggle to build a full data set when they are reporting on intervals where not all intervals are populated. For example, I want hourly sales figures across a day but, if we're selling something like cars, not every hour will always contain a sale"


No comments:

Post a Comment