fbpx

36. Date Ranges

This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
 

An interesting SQL exercise. Given a table that represents date ranges:


CREATE TABLE dates
(str_date date, end_date date)
GO

Carefully studying the table reveals that:

  • The range of days between the earliest date (02.02.2016) and the most recent date (16.02.2016) is 15 (15 days, because 02.02.2016 is included in the range).
  • Out of these 15 days, 4 dates do not appear in the table: 11.02.2016, 12.02.2016, 13.02.2016, 15.02.2016.

To read more

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…