>>>>> "Phil" == Phil Glatz <phil@stripped> writes:
Phil> for is a table with a series of row, one per day
Phil> when is a timedate field
Phil> select when,week(when) as wk from foo group by wk order by when;
Phil> This query does group properly on week numbers, but the date in the 'when'
Phil> column is a value from sometime within the week, but not necessarily the
Phil> starting day of the week - any way to make this column reflect the first
Phil> day of the week?
Note that the above query is illegal according to ansi SQL;
You can't mix group functions with normal fields!
Check the GROUP BY entry in the MySQL manual!
How about:
select min(when) as w,week(when) as wk from foo group by wk order by w;
?
Regards,
Monty
| Thread |
|---|
| • group by week() | Phil Glatz | 30 Apr |
| • group by week() | Michael Widenius | 30 Apr |