pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Ali Adams <aliadams@doit4u.com>
To: pgsql-sql@postgresql.org
Subject: Re: help yourself by helping others
Date: Thu, 10 Jul 2003 09:24:36 +0100
Message-ID: <200307100924.37218.dev@archonet.com> (raw)
In-Reply-To: <001c01c2fa9b$5b91ec80$03000000@DELLPC>
References: <001c01c2fa9b$5b91ec80$03000000@DELLPC>

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



view thread (8+ messages)  latest in thread

Message-ID: <200307100924.37218.dev@archonet.com>
Permalink:  ../200307100924.37218.dev@archonet.com/
Also on:    postgresql.org/message-id/200307100924.37218.dev@archonet.com

 · 

reply

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: dev@archonet.com, aliadams@doit4u.com
  Subject: Re: help yourself by helping others
  In-Reply-To: <200307100924.37218.dev@archonet.com>

* 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