I'm trying fetch the maximum date from the jsonb column.
I'm getting this below error..
------------------------------------
id | obj_value(jsonb)
------------------------------------
1 | {"value": [{"date": "2020-12-2020"}]}
------------------------------------
2 | {"value": [{"date": "2020-12-2019"}]}
---------------------------------
3 | {"value": [{"date": "2020-12-2018"}]}
---------------------------------
here is the SQL query
SELECT max(obj_value->'value'->0->'effectiveDate')
FROM public.tbl_data
where obj_value->'value'->0->>'effectiveDate' <= TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD')
I'm getting this below error..
ERROR: function max(jsonb) does not exist
LINE 1: SELECT max(obj_value->'value'->0->'effectiveDate')
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 8
question from:
https://stackoverflow.com/questions/65871674/query-jsonb-fields-in-the-postgres-sql 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…