From: | "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt> |
---|---|
To: | "Wes James" <comptekki(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: sum an alias |
Date: | 2010-06-04 13:44:24 |
Message-ID: | DA8DA6F7EB614E649E8BB3154CEEDEC0@marktestcr.marktest.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
----- Original Message -----
From: "Wes James" <comptekki(at)gmail(dot)com>
To: <pgsql-sql(at)postgresql(dot)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(dot)kretschmer(at)schollglas(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Nilesh Govindarajan | 2010-06-06 02:30:46 | Difference between these two queries ? |
Previous Message | Wes James | 2010-06-04 13:30:18 | Re: sum an alias |