Page 1 of 1

SQL Grouping

Posted: 06.09.2010, 11:57
by akli_agha
Hi,

I want to group my data by 2 groups. My criteria is a date.
Then one group would be before this date and the other group after this date. How to write the sql script to have this ??

D7, FB2.0, XP SP2

Thanks.

Posted: 06.09.2010, 12:33
by Wild_Pointer
akli_agha,

SELECT sum(price) FROM payments
group by case when sale_date > '2010.01.01' then 1 else 2 end

At least this works for postgresql.

Good luck.

Posted: 06.09.2010, 17:50
by akli_agha
Thanks Wild_Pointer,

It works on firebird too.