tags:

views:

45

answers:

4

i would like to display results for values that are only 10 and over

select  name, count(*) from actor
join casting on casting.actorid = actor.id
where casting.ord = 1
group  by name
order by 2 desc

that will return this:

name    count(*)
Sean Connery    19
Harrison Ford   19
Robert De Niro  18
Sylvester Stallone  18

etc

but i want to return values of count(*) that are only above 10

how do i do this? with having?

+3  A: 

Yes.

HAVING COUNT(*)>10
Ignacio Vazquez-Abrams
where should it be placed?
I__
+2  A: 

Try this

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
RRUZ
A: 

You should use having clause for this.

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
KandadaBoggu
My scoreboard shows a -ve vote for my answer? What's wrong with my answer?
KandadaBoggu
wasnt me. its good
I__
A: 
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
ultrajohn