Search Postgresql Archives

Re: DISTINCT *and* ORDER BY in aggregate functions on expressions(!)y

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 :-)






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux