GROUP BY MONTH?
Paul Gaspar
devlist at revolversoft.com
Sat Dec 27 22:42:31 CST 2008
Hi all,
is there any way to GROUP BY a datepart like MONTH or YEAR?
When I try this:
SELECT mydate AS mytest, SUM(mynumber)
FROM table
GROUP BY MONTH(mydate)
then I get an unexpected token ( error. Also GROUP BY mytest does not
work (which is the syntax for a HAVING clause).
Of course there is an workaround with methods mydate_year=YEAR(mydate)
and same with month:
SELECT mydate AS mytest, SUM(mynumber)
FROM table
GROUP BY mydate_year, mydate_month;
This works, but then I have to create methods for every possible
datepart (like week, quarter), which is not very nice.
Thanks,
Paul
More information about the Valentina
mailing list