|
|
Re: 看来还要抛砖
最初由 easyfree 发布
[B]
1. 要考虑重复的问题, 比如上述例子里面, 加一row: a 1 , 那么=-3就不行了,需要<=-3
2. 要考虑效率问题, 其实语句还应当加入一个where条件: where number not in (1,3,5), 这样, 即便应用中出现: 包含1,3, -6这样的要求, 也还是通用的
这样, 最简单的写法就是:
select name
from test
where number not in (1,3,5)
group by name
having count(distinct number)=3 [/B]
哇!你这样写也是很经典的呀!!!
但是根据人家的意思,是不是要在where子句中这样写呢:
where number in (1,3,5)
就是把not去掉哦! :) |
|