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
 General SQL Server Forums
 New to SQL Server Programming
 Help with query

Author  Topic 

petit16
Starting Member

1 Post

Posted - 2011-01-09 : 11:10:33
Hi i need some help with this query i've got 2 tables about MUSIC
-SONGS
-ARTIST
-CDMUSIC

so i need to see the CD with the max number of songs i arrive at this point, as you can see i've got every CD with the numer of songs but not the only one which has the max number of songs

SELECT CodDisco,COUNT(*) as Total from SONGS
group by CodDisco

Thank you

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-09 : 12:51:58
[code]
SELECT TOP 1 CodDisco,COUNT(*) as Total from SONGS
group by CodDisco
ORDER BY Total DESC
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -