Re: need help with query, how to fold select result to array?
В списке pgsql-general по дате отправления:
| От | Sam Mason |
|---|---|
| Тема | Re: need help with query, how to fold select result to array? |
| Дата | |
| Msg-id | 20100112144144.GH5407@samason.me.uk обсуждение |
| Ответ на | Re: need help with query, how to fold select result to array? (Sergey Levchenko <sector119@gmail.com>) |
| Список | pgsql-general |
On Tue, Jan 12, 2010 at 04:06:20PM +0200, Sergey Levchenko wrote:
> but I have to fold it in multi-dimensional, array like {{71629130,
> 15518, 0}, {2668722, 616, 0}} ?
> but it's not possible to pass more then one argument to the array_agg
> function :/
Tuples work fine. Multidimensional arrays are awfully complicated and
it's generally better to stay away from them, arrays of tuples make more
sense. Maybe something like:
CREATE TYPE meterreading (
meter_id INT,
org_reading NUMERIC,
reading NUMERIC
);
SELECT office_id, serial, commit_date, service_id,
array_agg(row(meter_id, organization_reading, reading)::meterreading) AS readings
FROM meter_readings;
--
Sam http://samason.me.uk/
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера