From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Dani Castaños <danitao(dot)mailists(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Get different sums from the same table in one query |
Date: | 2007-10-08 11:37:09 |
Message-ID: | 470A1665.6030500@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Dani Castaños wrote:
> 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
Is this what you mean?
SELECT message_type_id, to_char...
...
WHERE message_type_id IN (4,5,6,21)
...
GROUP BY message_type_id, date_id
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2007-10-08 11:59:06 | Re: Get different sums from the same table in one query |
Previous Message | Peter Childs | 2007-10-08 11:32:55 | Re: Get different sums from the same table in one query |