我想显示仅为10及以上的值的结果
select name, count(*) from actor
join casting on casting.actorid = actor.id
where casting.ord = 1
group by name
order by 2 desc
将返回此信息:
name count(*)
Sean Connery 19
Harrison Ford 19
Robert De Niro 18
Sylvester Stallone 18
等
但我想返回只有10以上的count(*)值
我该怎么做?有吗?
答案 0 :(得分:3)
是
HAVING COUNT(*)>10
答案 1 :(得分:2)
试试这个
select name, count(*) from actor
join casting on casting.actorid = actor.id
where casting.ord = 1
group by name
having count(*)>10
order by 2 desc
答案 2 :(得分:0)
您应该使用having
子句。
select name, count(*) from actor
join casting on casting.actorid = actor.id
where casting.ord = 1
group by name
having count(*) > 10
order by 2 desc
答案 3 :(得分:0)
select name, count(*) from actor
join casting on casting.actorid = actor.id
where casting.ord = 1
group by name having count(*) > 10
order by 2 desc