pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bronx <tobronx@go2.pl>
To: pgsql-admin@postgresql.org
Subject: Is it possible in PostgreSQL?
Date: Tue, 13 Jan 2004 00:58:52 +0100
Message-ID: <00ca01c3d968$07c05fe0$0201a8c0@bronx> (raw)

Hi,
I've got problem with one specific query. I've got the table
with many of rekords like these:

name     |  quantity    | date
-------------------------------------------------------
aaa            2                2003-04-01
bbb            4                2003-04-12
ccc            5                2003-05-12
aaa            3                2003-01-14
aaa            1                2003-12-09
bbb            9                2003-08-08

and so on ...

Does anybody know how make query which return grouped 
records by month of year and name (also sum of quantity). 
It is possible to make a query whitch return something like that:

name | 01 | 02 | 03 | 04 | ... | 12 (months)
------------------------------------------------
aaa     x     x     x    x    ...   x
bbb     x     x     x    x    ...   x
ccc     x     x     x    x    ...   x

where x means sum of quantity in month.
It is possible to make it in one query?
I know that in Access is construction : PIVOT.

Thanks 
Adam

view thread (4+ messages)  latest in thread

Message-ID: <00ca01c3d968$07c05fe0$0201a8c0@bronx>
Permalink:  ../00ca01c3d968$07c05fe0$0201a8c0@bronx/
Also on:    postgresql.org/message-id/00ca01c3d968$07c05fe0$0201a8c0@bronx

 · 

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: tobronx@go2.pl, pgsql-admin@postgresql.org
  Subject: Re: Is it possible in PostgreSQL?
  In-Reply-To: <00ca01c3d968$07c05fe0$0201a8c0@bronx>

* 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