O'Reilly logo
  • Dustin Waybright thinks this is interesting:

SELECT D.n AS theday, S.n AS shiftno FROM dbo.Nums AS D CROSS JOIN dbo.Nums AS S WHERE D.n <= 7 AND S.N <= 3 ORDER BY theday, shiftno;


Cover of Training Kit (Exam 70-461): Querying Microsoft® SQL Server® 2012


Using a single table/column of integers to mark 1-7 as the day and 1-3 as the shift to create every possible combination of day and shift.