Date functions

From SQLZoo

Group by day of the week (using date functions)

schema:gisq

We might want to count, or find the average by days of the week. This approach uses the date functions.

In this example we note that top of the pops usually goes out on a Thursday or Friday.

SELECT TO_CHAR(wk,'D'), COUNT(song)
  FROM gisq.totp
 GROUP BY TO_CHAR(wk,'D')
SELECT DAYOFWEEK(wk), COUNT(song)
  FROM totp
 GROUP BY DAYOFWEEK(wk)