----- Original Message ----- From: "Wes James" <compte...@gmail.com>
To: <pgsql-sql@postgresql.org>
Sent: Friday, June 04, 2010 2:30 PM
Subject: Re: [SQL] sum an alias


On Thu, Jun 3, 2010 at 11:54 PM, A. Kretschmer
<andreas.kretsch...@schollglas.com> wrote:
In response to Wes James :
In the statement:

select
MAX(page_count_count) - MIN(page_count_count) as day_tot,
MAX(page_count_count) as day_max, sum(MAX(page_count_count) -
MIN(page_count_count)) as tot,
page_count_pdate
from page_count
group by page_count_pdate order by page_count_pdate

Is there a way to do sum(day_tot) also in the same statement?



You can use a nested SELECT.
Is there some reason preventing you from doing that?

Why don't you do something like
SELECT SUM(day_tot)
FROM (
select
MAX(page_count_count) - MIN(page_count_count) as day_tot,
MAX(page_count_count) as day_max,
page_count_pdate
from page_count
group by page_count_pdate order by page_count_pdate );

Maybe I 'm misunderstanding the background of what you want to do

Best,
Oliveiros


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to