List:General Discussion« Previous MessageNext Message »
From:Graeme B. Davis Date:February 2 2001 9:52pm
Subject:GROUPing question
View as plain text  
I have a GROUPing question on the following query:

SELECT HOUR(closedtime) AS hour, COUNT(assignedto) AS count FROM db WHERE
(closedtime >='2001-01-01' AND closedtime <= '2001-01-31 23:59:59') AND
assignedto='person' GROUP BY hour;

give something like this:

+------+------------+-------+
| hour | prettyhour | count |
+------+------------+-------+
|    8 | 8AM        |    40 |
|    9 | 9AM        |   161 |
|   10 | 10AM       |   265 |
|   11 | 11AM       |   177 |
|   12 | 12PM       |   213 |
|   13 | 1PM        |    93 |
|   14 | 2PM        |   119 |
|   15 | 3PM        |   105 |
|   16 | 4PM        |   129 |
|   17 | 5PM        |    77 |
|   18 | 6PM        |    42 |
|   19 | 7PM        |     5 |
|   20 | 8PM        |     9 |
|   21 | 9PM        |     6 |
|   22 | 10PM       |     7 |
|   23 | 11PM       |     2 |
+------+------------+-------+
16 rows in set (4.71 sec)

Is there a way to get the AVG count per day over this range instead of the
above total (in one query)?

I can't seem to find info on grouping by several things.

Thanks!

Graeme

Thread
GROUPing questionGraeme B. Davis2 Feb
  • Re: GROUPing questionBob Hall3 Feb
RE: GROUPing questionSeng Ung5 Feb