Finding SQL Users who satisfy two different conditions -
i have table following:
user id || quality_a 200; 1 15; 3 35; 7 76; 6 200; 5
if want find users such exists row users quality 1, , exists row users quality 5, how do so. instance, in table above, user 200 has 2 rows, , qualities respectively 1 , 5. counted.
also, should titled appreciated.
you can try this
select user_id table1 quality_a in (1,5) group user_id having count(distinct quality_a) >= 2
Comments
Post a Comment