Postgres version 11.10
Here is my postgres schema which uses a jsonb field
create table data(
key char(32), --md5
time int NOT NULL,
output jsonb NOT NULL,
PRIMARY KEY (key,time)
)
Here are two queries that works just fine
select distinct on(key) key from data ORDER BY key,time DESC
select distinct on(key) key,output from data ORDER BY key,time DESC
the problem is this query
select distinct on(key) key,output-->details from data ORDER BY key,time DESC
I keep getting the error
column "key" does not exist
Any idea why?