I am trying to get the opportunity equals resales from the following JSONB array in Postgres. But I can't seems to figure it out.
{
"done": true,
"size": 106,
"records": [{
"Name": "FEF",
"IsActive": true,
"attributes": {
"price": "3",
"width": "20"
},
"Description": null,
"Opportunity": "Resale"
}, {
"Name": "DHQ",
"IsActive": true,
"attributes": {
"price": "300",
"width": "10000"
},
"Description": null,
"Opportunity": "Resale"
}]
}
SELECT salesdata
FROM public.salesdata
where salesdata -> 0 ->> '"records":[{"Opportunity":"Resale"}]';
Error:
SQL Error [42804]: ERROR: argument of WHERE must be type boolean, not type text