GROUP BY MONTH?

Thorsten Hohage thohage at genericobjects.de
Sun Dec 28 02:57:11 CST 2008


Hi Paul,

On 2008-12-28, at 05:42, Paul Gaspar wrote:

> is there any way to GROUP BY a datepart like MONTH or YEAR?

Yes, and you don't need to create functions / calculated columns for  
all group by values you want to use. After teached by Ivan often  
enough I'm now the happy to answer

Use this query

	SELECT YEAR(mydate), MONTH(mydate), mynumber
   	FROM table

as a inner select statement and then do


	SELECT Y1, M1, sum(mynumber) from
   		(SELECT YEAR(mydate) Y1, MONTH(mydate) M1, mynumber
   		FROM table)
	GROUP BY Y1, M1

and you're done.

regards,

Thorsten Hohage
-- 

Valentina Technology Evangelist
generic objects  GmbH - Leiter Solution Center Nord



More information about the Valentina mailing list