New answers tagged

0

try this update json_test set filter_data = jsonb_set( filter_data , array['task_packets', elem_index::text, 'state'], '"DONE"'::jsonb, true) from ( select pos- 1 as elem_index id from json_test, jsonb_array_elements(filter_data ) with ordinality arr(...


1

You should use a comparison operator like > < = >= <= create table t (id int); select case when (select count(*) from t) then 1 else 0 end ERROR: argument of CASE/WHEN must be type boolean, not type bigint LINE 1: select case when (select count(*) from t) then 1 else 0 end select case when (select count(*) from t) > 0 then 1 else 0 end ...


0

Add a COUNT() column: select emp_id, sum(case when leave_type = 'Planned' then 1 else 0 end) Planned, sum(case when leave_type = 'Not Informed' then 1 else 0 end) NotInformed, sum(case when leave_type = 'Informed' then 1 else 0 end) Informed, count(*) as Total from t where activity_type='Leave' group by emp_id; emp_id | planned | notinformed | ...


Top 50 recent answers are included