Re: pivoting, crosstabbing and almost there !

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: pivoting, crosstabbing and almost there !
Дата
Msg-id 20020725121958.X50051-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на pivoting, crosstabbing and almost there !  (robert kraus <rob_kra@yahoo.com>)
Список 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;



В списке pgsql-general по дате отправления:

Предыдущее
От: robert kraus
Дата:
Сообщение: pivoting, crosstabbing and almost there !
Следующее
От: Andrew Sullivan
Дата:
Сообщение: archives dead again?