From: Oliveiros <oliveiros.cristina@marktest.pt>
To: Wes James <comptekki@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: how to construct sql
Date: Wed, 2 Jun 2010 17:55:18 +0100
Message-ID: <597755AB8EE8458F92F4B7C6588E5C03@marktestcr.marktest.pt> (raw)
References: <AANLkTik3O3L0PLqy4SN5oHy9zSBf8TDLXzGZcPYLtEXf@mail.gmail.com>
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
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: oliveiros.cristina@marktest.pt, comptekki@gmail.com
Subject: Re: how to construct sql
In-Reply-To: <597755AB8EE8458F92F4B7C6588E5C03@marktestcr.marktest.pt>
* 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