SQL Grouping

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
akli_agha
Junior Boarder
Junior Boarder
Posts: 41
Joined: 08.01.2008, 20:35

SQL Grouping

Post 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.
Wild_Pointer
Expert Boarder
Expert Boarder
Posts: 164
Joined: 18.03.2008, 13:03
Contact:

Post 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.
akli_agha
Junior Boarder
Junior Boarder
Posts: 41
Joined: 08.01.2008, 20:35

Post by akli_agha »

Thanks Wild_Pointer,

It works on firebird too.
Post Reply