Advertisement
VladoG

[DB] SQL-Built-in functions - 15. Duration & Part of the Day

Feb 14th, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.49 KB | None | 0 0
  1. SELECT
  2.     Name AS [Game],
  3.     CASE
  4.         WHEN DATEPART(HOUR, START) BETWEEN 0 AND 11 THEN 'Morning'
  5.         WHEN DATEPART(HOUR, START) BETWEEN 12 AND 17 THEN 'Afternoon'
  6.         WHEN DATEPART(HOUR, START) BETWEEN 18 AND 23 THEN 'Evening'
  7.     END AS [Part OF the DAY],
  8.     CASE
  9.         WHEN Duration <= 3 THEN 'Extra Short'
  10.         WHEN Duration BETWEEN 4 AND 6 THEN 'Short'
  11.         WHEN Duration > 6 THEN 'Long'
  12.         WHEN Duration IS NULL THEN 'Extra Long'
  13.     END AS [Duration]
  14.     FROM Games
  15. ORDER BY [Game], [Duration], [Part OF the DAY]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement