SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table t ( id int, c1 int, c2 int, c3 int, c4 int, c5 int, c6 int, c7 int, sts int ); insert into t values (1, 1, 0, 0, 2, 1, 1, 1, 0), (2, 1, 0, 0, 2, 1, 1, 1, 0), (3, 0, 0, 0, 1, 1, 1, 1, 0), (4, 0, 0, 0, 0, 1, 1, 1, 0) ; SELECT id FROM t, jsonb_each_text(to_jsonb(t)) as x("key",val) group by id having count(*) filter(where val::int = 0) <=3 and count(*) filter(where val::int = 1) <=4;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear