From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | robert kraus <rob_kra(at)yahoo(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: pivoting, crosstabbing and almost there ! |
Date: | 2002-07-25 19:22:52 |
Message-ID: | 20020725121958.X50051-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> I am trying to get a pivoted result from a query. The
> pivoting works, however I want to eliminate
> some of the rows, which have no value at all in every
> column but the name column.
Maybe something like:
SELECT * from (
SELECT students.name,
( SELECT score FROM scores
WHERE (
students.name = scores.name
AND
scores.exam = 'first'
AND
scores.score > '70'
)
) AS first,
( SELECT score FROM scores
WHERE (
students.name = scores.name
AND
scores.exam = 'second'
AND
scores.score > '80'
)
) AS second,
( SELECT score FROM scores
WHERE (
students.name = scores.name
AND
scores.exam = 'third'
AND
scores.score > '90'
)
) AS third
FROM students
) AS c
where c.first is not null or c.second is not null or
c.third is not null;
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2002-07-25 19:42:13 | archives dead again? |
Previous Message | robert kraus | 2002-07-25 18:45:18 | pivoting, crosstabbing and almost there ! |