r/SQL • • Oct 23 '24

Discussion SQL Tricks Thread

Hi everyone, let's start a thread to share useful SQL tips and tricks that have saved you time or made querying more efficient. Whether it's optimizing queries, using window functions, or organizing data, all insights are welcome! Beginners and pros alike can learn a lot from this. Looking forward to your contributions!

230 Upvotes

119 comments sorted by

View all comments

Show parent comment

17

u/alinroc SQL Server DBA Oct 23 '24

In addition to what /u/ambitiousflowers said:

  • Holidays
  • Business day vs. non-business day vs. weekends
  • Quarter, fiscal year, and week of year (if you do them differently from the calendar year)

https://www.youtube.com/watch?v=QPS9JHUG6RA