Re: help yourself by helping others - Mailing list pgsql-sql

From Michael A Nachbaur
Subject Re: help yourself by helping others
Date
Msg-id 200307101300.43414.mike@nachbaur.com
Whole thread Raw
In response to help yourself by helping others  ("Ali Adams" <aliadams@doit4u.com>)
List pgsql-sql
On Friday 04 April 2003 03:10 am, Ali Adams wrote:
> Dear All,
>
> I am new to Relational Databases and SQL and my background in ODBs is
> clouding my way to solving what seems to be a simple problem. I am sure
> many of you have met it many times.
<snip>

Assuming you can have multiple records per day per machine (e.g. you're 
polling for information throughout the day), the following holds.  However, 
the output doesn't provide for a separate column per day, but rather you get 
a separate row for each day/machine combination.

Attached is a file that demonstrates the behavior I think you would like.  But 
basically, here is the SQL statement you're looking for:

SELECT Datestamp, Machine, SUM(Withdrawls)
FROM WithdrawlsTable
GROUP BY Machine, Datestamp
ORDER BY Datestamp, Machine;

-- 
/* Michael A. Nachbaur <mike@nachbaur.com>* http://nachbaur.com/pgpkey.asc*/

"A thought seemed to strike the woman. It struck her very slowly. You could 
watch it coming in like a long wave on a sandy beach."

pgsql-sql by date:

Previous
From: Michael Pohl
Date:
Subject: Re: substr_count
Next
From: Rod Taylor
Date:
Subject: Re: help yourself by helping others