Re: need help with query, how to fold select result to array?

Поиск
Список
Период
Сортировка
От Sergey Levchenko
Тема Re: need help with query, how to fold select result to array?
Дата
Msg-id e3ffbf241001120626s4b9e6d04qf6cab75d07b7cf1a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: need help with query, how to fold select result to array?  (Sergey Levchenko <sector119@gmail.com>)
Список pgsql-general
CREATE TYPE varchararray AS (f varchar[]);

SELECT office_id, serial, commit_date, service_id,
              array_agg(DISTINCT ROW(ARRAY(SELECT meter_id::varchar UNION ALL

SELECT organization_reading::varchar UNION ALL

SELECT reading::varchar))::varchararray)
FROM meter_readings
WHERE office_id = 134 AND
      serial = 27 AND
      commit_date = '2010-01-11' AND
      commit_time = '13:44:37' AND
      person_id = 300871
GROUP BY office_id, serial, commit_date, service_id;

 office_id | serial | commit_date | service_id |
array_agg
-----------+--------+-------------+------------+------------------------------------------------------
       134 |     27 | 2010-01-11  |          2 |
{"(\"{2668722,616,0}\")","(\"{71629130,15518,0}\")"}
       134 |     27 | 2010-01-11  |          4 | {"(\"{019210,372,0}\")"}
       134 |     27 | 2010-01-11  |         75 | {"(\"{111029,9505,0}\")"}
(3 rows)


I want something like that, but without varchararray type;
parentheses, slashes and " in array_agg field, where does it get from?

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

Предыдущее
От: Vincenzo Romano
Дата:
Сообщение: Re: Weird EXECUTE ... USING behaviour
Следующее
От: "Andrus"
Дата:
Сообщение: How to find column type