Re: Query how-to - Mailing list pgsql-sql

From Marc Mamin
Subject Re: Query how-to
Date
Msg-id CA896D7906BF224F8A6D74A1B7E54AB30455CE74@JENMAIL01.ad.intershop.net
Whole thread Raw
In response to Query how-to  (Montaseri <montaseri@gmail.com>)
Responses Re: Query how-to
List pgsql-sql
<br /><p><font size="2">Hi,<br /><br /> What about something like that ?<br /><br /> select adate, sum(openedCount) as
openedCount,sum(closedCount) as closedCount<br /> from<br /> (<br />   select sum(case when status ='Closed' then
stop_dateelse start_date end) as adate,<br />        sum(case when status ='Closed' then 1 else 0 end) as
closedCount<br/>        sum(case when status ='New' then 1 else 0 end) as openedCount<br />   from  Yourtable<br />  
wherestatus in ('Closed','New')<br /> )x<br /> group by adate<br /> order by adate<br /><br /> HTH,<br /><br /> Marc<br
/></font>

pgsql-sql by date:

Previous
From: Frank Bax
Date:
Subject: Re: Query how-to
Next
From: Raj Mathur
Date:
Subject: For each key, find row with highest value of other field