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)
 DECS is throwing an error?

Author  Topic 

jgonzalez14
Yak Posting Veteran

73 Posts

Posted - 2008-11-23 : 12:33:42
When I insert decs in to this statement it throws an error. What am I doing wrong?

SELECT m.title,count(r.rating) as NumofRatings
FROM movies m
inner join ratings r
on m.movieid = r.movieid
group by r.rating
having count(r.rating) >25 desc;

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-23 : 12:37:33
[code]SELECT m.title,count(r.rating) as NumofRatings
FROM movies m
inner join ratings r
on m.movieid = r.movieid
group by r.rating
having count(r.rating) >25
order by NumofRatings desc[/code]
Go to Top of Page

jgonzalez14
Yak Posting Veteran

73 Posts

Posted - 2008-11-23 : 12:39:11
That works!!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-23 : 12:46:57
yup...desc/asc option should be given with order by not with having
Go to Top of Page
   

- Advertisement -