Re: how to construct sql - Mailing list pgsql-sql

From Plugge, Joe R.
Subject Re: how to construct sql
Date
Msg-id BD69807DAE0CE44CA00A8338D0FDD08302D2E1856A@oma00cexmbx03.corp.westworlds.com
Whole thread Raw
In response to Re: how to construct sql  ("Hiltibidal, Rob" <Rob.Hiltibidal@argushealth.com>)
Responses Re: how to construct sql  (Wes James <comptekki@gmail.com>)
List pgsql-sql
This is discussed in this Wiki:


http://wiki.postgresql.org/wiki/Grouping_Sets



-----Original Message-----
From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Hiltibidal, Rob
Sent: Wednesday, June 02, 2010 12:06 PM
To: Oliveiros; Wes James; pgsql-sql@postgresql.org
Subject: Re: [SQL] how to construct sql

db2 has a group by rollup function.. does this exist in postgres?

-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Oliveiros
Sent: Wednesday, June 02, 2010 11:55 AM
To: Wes James; pgsql-sql@postgresql.org
Subject: Re: [SQL] how to construct sql

Hi,
Have you already tried this out?

select MAX(page_count_count) - MIN(page_count_count)
from page_count
group by page_count_pdate.


Best,
Oliveiros

----- Original Message -----
From: "Wes James" <comptekki@gmail.com>
To: <pgsql-sql@postgresql.org>
Sent: Wednesday, June 02, 2010 5:48 PM
Subject: [SQL] how to construct sql


>I am grabbing a printer total and putting it in a table.  The
> page_count is continuously increasing:
>
> page_count_count        page_count_pdate
> 10                               2010-05-10
> 20                               2010-05-10
> 40                               2010-05-11
> 60                               2010-05-11
> 80                               2010-05-11
> 100                               2010-05-12
> 120                               2010-05-12
> .....
>
> and so on.
>
> I can do:
>
> select sum(page_count_count) from page_count group by
page_count_pdate.
>
> and get a total for a day.  But this is not the total I want.  I want
> the total page count for the day.  This would mean getting the first
> page count of the day and then subtracting that from last page_count
> for the day.  For 2010-05-11 above it would be
>
> 80 - 40 = 40 total for the day.  Is there a way to do this with sql?
>
> thx,
>
> -wes
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql

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

PRIVILEGED AND CONFIDENTIAL
This email transmission contains privileged and confidential information intended only for the use of the individual or
entitynamed above.  If the reader of the email is not the intended recipient or the employee or agent responsible for
deliveringit to the intended recipient, you are hereby notified that any use, dissemination or copying of this email
transmissionis strictly prohibited by the sender.  If you have received this transmission in error, please delete the
emailand immediately notify the sender via the email return address or mailto:postmaster@argushealth.com.  Thank you. 





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


pgsql-sql by date:

Previous
From: jr
Date:
Subject: Re: safely exchanging primary keys?
Next
From: Wes James
Date:
Subject: Re: how to construct sql