Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 quicky

Author  Topic 

jgonzalez14
Yak Posting Veteran

73 Posts

Posted - 2008-11-24 : 18:52:49
For some reason this isn't working, I want to list all ratings and the number of movies for each rating where
the number of ratings is greater than 10,000.

SELECT distinct r.`rating`, count(distinct r.`movieid`) as "NumOFMovies"
FROM ratings r
group by r.rating
having count(r.movieid) > 10000;

Can any one help?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-11-24 : 19:25:06
does this work?
SELECT r.rating, count(distinct r.movieid) as "NumOFMovies"
FROM ratings r
group by r.rating
having count(distinct r.movieid) > 10000;
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-24 : 22:57:46
also dont use '' for column names.
Go to Top of Page
   

- Advertisement -