[<<][sql][>>][..]
Mon Nov 7 22:38:51 EST 2011

Histograms

Simple histograms need a "truncate" function like year, month, day
below.  Then the summary is a GROUP BY, optionally followed bya an
ORDER BY.

  SELECT year(date) AS year, count(*) AS hits FROM entry
  GROUP BY year(date)
  ORDER BY year;

  SELECT month(date) AS month, count(*) AS hits FROM entry
  GROUP BY month(date)
  ORDER BY month;

  SELECT day(date) AS day, count(*) AS hits FROM entry
  GROUP BY day(date)
  ORDER BY day;



[1] http://stackoverflow.com/questions/830814/sql-server-non-standard-date-based-histogram
[2] http://stackoverflow.com/questions/6201992/optimal-way-to-create-a-histogram-frequency-distribution-in-oracle




[Reply][About]
[<<][sql][>>][..]