Posts

Showing posts from March, 2023

SQL Server, multiple "GROUP BY" in a single statement? The GROUPING SETS explained in a CLEAR way and with EXAMPLES!

Image
Hi Guys!  Welcome back! Today we will talk about GROUPING SETS. As usual I will try to explain what we are talking about in the clearest possible way and we will always give examples . So what is a GROUPING SET? GROUPING SETS can be considered an extension of the GROUP BY clause in fact it gives you the possibility to combine multiple GROUP BY clauses . How many times do we have to show in video a series of data that maybe adding them up and regrouping them for more than one field? How many times have we had to use UNION clauses? Often many clauses union together make the code less readable and less maintainable. The solution is to use GROUPING SETS. Enjoy the reading!   GROUPING SETS  As said, a grouping set can be considered as an extension of the GROUP BY clause. Speaking in a technical way, SQL grouping sets are a way to group data in SQL queries by multiple dimensions. Now, in a typical SQL GROUP BY clause, data is grouped by one or mor...

"SQL Query Design Patterns and Best Practices" My review!

Image
Hi Guys! It’s been a while since the last post ...it’s been a lot of work! In the meanwhile SQL Server 2022 get its second CU ( download ) and SSMS has reached version 19.02 ( download ) However we are here and so … welcome! I must say I like to review books because this is also a good way to stay updated. For this I say a big thanks both the publisher Packt and the kind Nivedita Singh for offering me, once again, the opportunity to talk about their new book. Packt is an English publishing house known worldwide and specialized in books related to information technology , including programming, web design, data analysis and hardware . This new book will be published on March 22nd ( but yes you can preorded on Amazon here: https://packt.link/AYWje ) and it is related to the topic writing of Queries in SQL Server . Its title is " SQL Query Design Patterns and Best Practices " and the authors are: Steve Hughes, Dr. Ram Babu Singh, Leslie Andrews, Dennis Neer, Shabbir H. ...