Re: help yourself by helping others

From: Richard Huxton <dev(at)archonet(dot)com>
To: "Ali Adams" <aliadams(at)doit4u(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: help yourself by helping others
Date: 2003-07-10 08:24:36
Message-ID: 200307100924.37218.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2003-07-10 08:29:47 Re: trigger proceedures in sql
Previous Message David Witham 2003-07-10 07:56:18 Re: trigger proceedures in sql