GROUP BY MONTH?

Ruslan Zasukhin sunshine at public.kherson.ua
Sun Dec 28 04:01:53 CST 2008


On 12/28/08 11:20 AM, "Paul Gaspar" <devlist at revolversoft.com> wrote:

Hi Paul,
Hi Thorsten,

Good general way, although if table going to be big I afraid it is not best
by speed. Internal query will produce tmp ram table, and no index on that
fields.

IF you will need max speed for this task then I think better create Table
Method in this table

    YearOfDate     "year(mydate)"     INDEXED

And use it in the query

SELECT YearOfDate, ...
FROM table
GROUP BY YearOfDate


> Thank you, Thorsten! This works like charme.
> 
> Paulk
> 
> 
> 
> Am 28.12.2008 um 09:57 schrieb Thorsten Hohage:
> 
>> 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
>> 

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list