Get different sums from the same table in one query

Поиск
Список
Период
Сортировка
От Dani Castaños
Тема Get different sums from the same table in one query
Дата
Msg-id 470A0B20.40203@gmail.com
обсуждение исходный текст
Ответы Re: Get different sums from the same table in one query  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: Get different sums from the same table in one query  (Richard Huxton <dev@archonet.com>)
Список pgsql-sql
Hi all!

I want to put this three queries in only one... Take a look that the 
only thing that changes is the message_type_id. Any suggestions??
        SELECT TO_CHAR( statistics_date, 'DD/MM/YYYY') AS date_in, 
sum(total_num_messages)        FROM statistics_daily        WHERE message_type_id IN (4,5)        AND statistics_date =
CURRENT_DATE       AND telecom_operator_id <> 0        AND telephone_number IN ( $numbers )        GROUP BY date_in
 
        SELECT TO_CHAR( statistics_date, 'DD/MM/YYYY') AS date_in, 
sum(total_num_messages)        FROM statistics_daily        WHERE message_type_id IN (6)        AND statistics_date =
CURRENT_DATE       AND telecom_operator_id <> 0        AND telephone_number IN ( $numbers )        GROUP BY date_in
 
        SELECT TO_CHAR( statistics_date, 'DD/MM/YYYY') AS date_in, 
sum(total_num_messages)        FROM statistics_daily        WHERE message_type_id IN (21)        AND statistics_date =
CURRENT_DATE       AND telecom_operator_id <> 0        AND telephone_number IN ( $numbers )        GROUP BY date_in
 



Thank you in advance!


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

Предыдущее
От: Rodrigo De León
Дата:
Сообщение: Re: SQL query question
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: Get different sums from the same table in one query