matrix query?

From: Jim Mercer <jim(at)reptiles(dot)org>
To: pgsql-general(at)postgreSQL(dot)org
Subject: matrix query?
Date: 2002-08-01 19:07:32
Message-ID: 20020801190732.GA49828@reptiles.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


this is probably a more generic SQL question than a postgres specific one, but:

CREATE TABLE data
(
customer varchar(10),
widgets int,
day int
);

INSERT INTO DATA values('CustA', 5, 1);
INSERT INTO DATA values('CustA', 4, 2);
INSERT INTO DATA values('CustA', 9, 3);
INSERT INTO DATA values('CustB', 8, 1);
INSERT INTO DATA values('CustB', 3, 2);
INSERT INTO DATA values('CustB', 1, 3);
INSERT INTO DATA values('CustB', 1, 3);
INSERT INTO DATA values('CustC', 2, 1);
INSERT INTO DATA values('CustC', 2, 1);
INSERT INTO DATA values('CustC', 7, 2);
INSERT INTO DATA values('CustC', 1, 3);

what kind of select can i do to get:

Day CustA CustB CustC
1 5 8 4
2 4 3 7
3 9 2 1

--
[ Jim Mercer jim(at)reptiles(dot)org +1 416 410-5633 ]
[ I want to live forever, or die trying. ]

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2002-08-01 19:09:25 Re: getpid() function
Previous Message Hannu Krosing 2002-08-01 18:50:36 Re: getpid() function