Re: SQL Query Syntax help

Поиск
Список
Период
Сортировка
От Daniel Verite
Тема Re: SQL Query Syntax help
Дата
Msg-id 753eae4f-21b8-4aac-8687-e9a2b345dac1@manitou-mail.org
обсуждение исходный текст
Ответ на SQL Query Syntax help  ("srikkanth" <srikkanth16081991@rediffmail.com>)
Список pgsql-admin
    srikkanth wrote:

> Can you please help me in writing the syntax for the below mentioned

This looks like an UNPIVOT operation.

Here's a generic method that does this without having to specify the
columns individually, with the help of json functions:

SELECT ID, key, value FROM
  (SELECT ID, row_to_json(t.*) AS line FROM PivotTableName t) AS r
JOIN LATERAL json_each_text(r.line) on (key <> 'ID');


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite



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

Предыдущее
От: "srikkanth"
Дата:
Сообщение: SQL Query Syntax help
Следующее
От: Geoff Winkless
Дата:
Сообщение: Re: SQL Query Syntax help