The following bug has been logged on the website:
Bug reference: 13833
Logged by: Michael Milton
Email address: ttmigueltt(at)gmail(dot)com
PostgreSQL version: 9.4.4
Operating system: Fedora 22
Description:
It's probably easiest to link to the StackOverflow question I posted:
http://stackoverflow.com/questions/34472961/postgres-order-by-value-inside-json-causes-column-does-not-exist-error
The summary of it is that this query throws the error "column sets does not
exist", despite the fact that it is created in the SELECT clause:
SELECT
coalesce(block.name, 'Other') as name,
json_agg(set.data) as sets
FROM
set
FULL OUTER JOIN block ON set.block_id = block.id
GROUP BY block.id
ORDER BY sets