sql - Select a value that has a greater number of values -
let's have table one:
table t: b ------- 1 x | o 2 x | o 3 x | p 4 y | o 5 y | p 6 y | p 7 z | o 8 z | o 9 z | p
i want select values in column have greater number of values in column b.
for example, want select x, y, or z if have more o's p's.
i've made several attempts, can't figure out how this.
so, how can write query retrieve want?
edit: expected output be:
- 1 x 2 z
this sounds aggregation. this:
select t group having sum(b = 'o') > sum(b = 'p');
Comments
Post a Comment