Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Boolean aggregation
create table t (c1 text, c2 text); insert into t (c1, c2) values ('a','x'), ('a','y'), ('a','z'), ('b','x'), ('c','y'), ('d','x'), ('d','x'), ('e','x'), ('e','y'); -- not z select c1 from t group by c1 having not bool_or(c2 = 'z') ; -- only x select c1 from t group by c1 having bool_and(c2 = 'x') ; -- must have x and y and nothing else select c1 from t group by c1 having bool_or(c2 = 'x') and bool_or(c2 = 'y') and bool_and (c2 in ('x','y')) ; -- at least x and y select c1 from t group by c1 having bool_or(c2 = 'x') and bool_or(c2 = 'y') ;
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Movie Rating SQL Analysis Project
Timestamps in PostgreSQL
E-commerce Website SQL Analysis
PostreSQL: Full Outer Join
Comp
as
1258. Find the Start and End Number of Continuous Ranges
Pivot the Hard Way..
loggin_trigger-audit
PostreSQL: Subquery
stackse - search stackoverflow differently
Please log in to post a comment.