From: Richard Huxton <dev@archonet.com>
To: Dani CastaƱos <danitao.mailists@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Get different sums from the same table in one query
Date: Mon, 08 Oct 2007 12:37:09 +0100
Message-ID: <470A1665.6030500@archonet.com> (raw)
In-Reply-To: <470A0B20.40203@gmail.com>
References: <470A0B20.40203@gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, danitao.mailists@gmail.com
Subject: Re: Get different sums from the same table in one query
In-Reply-To: <470A1665.6030500@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox