Re: Query how-to

Поиск
Список
Период
Сортировка
От Marc Mamin
Тема Re: Query how-to
Дата
Msg-id CA896D7906BF224F8A6D74A1B7E54AB3039E8BEE@JENMAIL01.ad.intershop.net
обсуждение исходный текст
Ответ на Re: Query how-to  ("Marc Mamin" <M.Mamin@intershop.de>)
Список pgsql-sql
this was silly from me!
this should naturally look like this:
 select case when status ='Closed' then stop_date else start_date end
as adate,        sum(case when status ='Closed' then 1 else 0 end) as
closedCount,        sum(case when status ='New' then 1 else 0 end) as openedCount from  Yourtable where status in
('Closed','New')group by case when status ='Closed' then stop_date else start_date end 
 order by adate

Marc

> Hi,

> What about something like that ?

> select adate, sum(openedCount) as openedCount, sum(closedCount) as
closedCount
> from
> (
>   select sum(case when status ='Closed' then stop_date else start_date
end) as adate,
>        sum(case when status ='Closed' then 1 else 0 end) as
closedCount
>        sum(case when status ='New' then 1 else 0 end) as openedCount
>   from  Yourtable
>   where status in ('Closed','New')
> )x
> group by adate
> order by adate


В списке pgsql-sql по дате отправления:

Предыдущее
От: Mark Roberts
Дата:
Сообщение: Re: For each key, find row with highest value of other field
Следующее
От: Louis-David Mitterrand
Дата:
Сообщение: many-to-many relationship