:wink: 怎么把COUNT(*)出的数,当条件使用呢?例如我想查大于COUNT(*)出10的记录?
select a, count(*) as b
from table_name
where b>"10"
group by 1; 原帖由 liaosnet 于 2008-2-28 13:38 发表 http://bbs.chinaunix.net/images/common/back.gif
select a, count(*) as b
from table_name
where b>"10"
group by 1;
这个真的可以么?
需要having子句吧
select
a, count (*)
from table
group by a
having count (*) > 10
; 原帖由 ivhb 于 2008-2-28 14:36 发表 http://bbs.chinaunix.net/images/common/back.gif
这个真的可以么?
需要having子句吧
select
a, count (*)
from table
group by a
having count (*) > 10
;
确实得HAVING,没有的话行不通,用HAVING也就得使用count(*) ,而不能使用 count(*) as b....,having b > 10,这样提示
217: Column (b) not found in any table in the query (or SLV is undefined).
Error in line 1
Near character position 57
回复 #12 ivhb 的帖子
:mrgreen: 的确得用having
页:
1
[2]