Re: Return relation table data in a single value CSV
От | Richard Huxton |
---|---|
Тема | Re: Return relation table data in a single value CSV |
Дата | |
Msg-id | 200402172104.38307.dev@archonet.com обсуждение исходный текст |
Ответ на | Return relation table data in a single value CSV (<terry@ashtonwoodshomes.com>) |
Ответы |
Re: Return relation table data in a single value CSV
|
Список | pgsql-sql |
On Tuesday 17 February 2004 20:05, terry@ashtonwoodshomes.com wrote: > I should probably be punished for even asking this question, but a > simplified version of what I want is this... > > I have 2 tables: > floorplans > floorplan_id | description > -------------------------- > 2240 | test floorplan > > and a table elevations > floorplan_id | elevation > ------------------------ > 2240 | A > 2240 | B > 2240 | C > > I want to perform a query that returns this result set: > baseplan_id | elevations > 2240 | A,B,C You've got two options here: 1. Write a set-returning function in plpgsql (or whatever) to do your looping and build the CSV value. Perhaps look in the contrib/ folder too - might be something in the tablefunc section. 2. Write a custom aggregate function (like sum()) to do the concatenation. This is easy to do, but the order your ABC get processed in is undefined. You can find info on both in the archives, probably with examples. Also - check techdocs. -- Richard Huxton Archonet Ltd
В списке pgsql-sql по дате отправления: