Re: sum an alias
От | Oliveiros d'Azevedo Cristina |
---|---|
Тема | Re: sum an alias |
Дата | |
Msg-id | DA8DA6F7EB614E649E8BB3154CEEDEC0@marktestcr.marktest.pt обсуждение исходный текст |
Ответ на | sum an alias (Wes James <comptekki@gmail.com>) |
Список | pgsql-sql |
----- Original Message ----- From: "Wes James" <comptekki@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.kretschmer@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_countgroup by page_count_pdate order by page_count_pdate ); Maybe I 'm misunderstanding the background of what you want to do Best, Oliveiros
В списке pgsql-sql по дате отправления: