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

From Richard Huxton
Subject Re: help yourself by helping others
Date
Msg-id 200307100924.37218.dev@archonet.com
Whole thread Raw
In response to help yourself by helping others  ("Ali Adams" <aliadams@doit4u.com>)
List pgsql-sql
On Friday 04 Apr 2003 12:10 pm, 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.
>
> OK, I have a table as follows:
>
>
> ID Machine   Date             Withdrawals
> 1  1              01/01/2003    1101
> 2  2              01/01/2003    2101
> 3  3              01/01/2003    3101
[snip]
> And i would like to create a monthly withdrawals report as follows:
>
> Machine   Day1  Day2  Day3  Day4............ Day31

Two options - either do it in your app or write a crosstab function.

You can extract the day part of the month using: SELECT EXTRACT('day' FROM now());

You can find some crosstab functions in the contrib/tablefunc directory of the
source distribution (or possibly as a package if installed as binary)



--  Richard Huxton


pgsql-sql by date:

Previous
From: "David Witham"
Date:
Subject: Re: trigger proceedures in sql
Next
From: Richard Huxton
Date:
Subject: Re: trigger proceedures in sql