Date functions

From SQLZOO
Revision as of 15:14, 17 July 2012 by Marek (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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)
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense