Unpivot / uncrosstab support?
От | |
---|---|
Тема | Unpivot / uncrosstab support? |
Дата | |
Msg-id | C237184E7081314392F31AE826947FFA44E19DF94C@EXWA-MBX01.nexus.csiro.au обсуждение исходный текст |
Ответы |
Re: Unpivot / uncrosstab support?
|
Список | pgsql-general |
Hi, I was wondering if Postgresql (8.3 or later) had an equivalent function to the MS-SQL function "unpivot"? I've spotted theuser contributed crosstab which is similar to the "pivot" function, but I can't find an equivalent "uncrosstab". Essentially what I'm trying to do is take a table like this... clientID clientName contact1 contact2 contact3 contact4 ----------- -------------------- ----------- ----------- ----------- ----------- 1 ABC Corp 1 34 2 NULL 2 DEF Foundation 6 2 8 9 3 GHI Inc. 5 9 NULL NULL 4 XYZ Industries 24 NULL 6 NULL ...and get a result like this... clientID ContactNumber ContactID ----------- ----------------------- ----------- 1 contact1 1 1 contact2 34 1 contact3 2 2 contact1 6 2 contact2 2 2 contact3 8 2 contact4 9 3 contact1 5 3 contact2 9 4 contact1 24 4 contact3 6 Which can be accomplished with unpivot. For more info I've stolen the example from http://weblogs.sqlteam.com/jeffs/archive/2008/04/23/unpivot.aspx Thanks Josh Vote
В списке pgsql-general по дате отправления: