From: | Thorsten Glaser <tg(at)evolvis(dot)org> |
---|---|
To: | Alban Hertroys <haramrae(at)gmail(dot)com> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: DISTINCT *and* ORDER BY in aggregate functions on expressions(!)y |
Date: | 2023-03-03 19:32:14 |
Message-ID: | 9e86b053-a29a-a82-78f0-1228a391edc3@evolvis.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, 3 Mar 2023, Alban Hertroys wrote:
>You can rewrite that into something like this:
>
>select jsonb_build_object('opening_times’,
> obj
> ORDER BY
> obj->>'weekday’,
> obj->>'from_hour’,
> obj->>'to_hour')
>)
>from cot
>cross join lateral jsonb_agg(jsonb_build_object(
> 'weekday', cot.weekday,
> 'from_hour', cot.from_hour,
> 'to_hour', cot.to_hour) obj
But isn’t that the same as with a regular LEFT JOIN?
>> cgwaj AS (
>> SELECT cgwa.id AS id, jsonb_build_object(
>> 'weekday', cgwa.weekday,
>> 'forenoon', cgwa.forenoon,
>> 'afternoon', cgwa.afternoon,
>> 'evening', cgwa.evening) AS obj
>> FROM core_generalworkavailability cgwa
plus
>> LEFT JOIN cgwaj ON cgwaj.id=cppwt.generalworkavailability_id
With the addition that I can aggregate…
bye,
//mirabilos
--
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2023-03-03 20:51:03 | Re: Converting row elements into a arrays? |
Previous Message | Peter Geoghegan | 2023-03-03 18:09:01 | Re: PG16devel - vacuum_freeze_table_age seems not being taken into account |