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)
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects
  • Your server today is: digitalocean-sqlzoo