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>
Re: SQL Query Syntax help "Daniel Verite" <daniel@manitou-mail.org>
Re: SQL Query Syntax help Geoff Winkless <pgsqladmin@geoff.dj>
	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
FAQ