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