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
 how to do ASC and DESC in SQL

Author  Topic 

ddeme
Starting Member

3 Posts

Posted - 2014-01-22 : 16:04:20
This is my data which had two tables
album(asin, title, artist, price, release, label, rank)
track(album, dsk, posn, song)

This is my question
Wagner's Ring cycle has an imposing 173 tracks, Bing Crosby clocks up 101 tracks.

List albums so that the album with the most tracks is first. Show the title and the number of tracks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-01-22 : 16:28:20
Show us what you have tried so far as this is obviously a homework question. We will help with homework but won't do your homework for you.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

ddeme
Starting Member

3 Posts

Posted - 2014-01-22 : 16:45:19
SELECT title, count(asin)
FROM album join track on (asin=album)
ORDER BY count(*) DESC

this is how i tried and the result is i am getting the total count

title count(asin)
The Very Best Of Elvis Costello And The Attraction 3267

Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-01-22 : 18:12:20
You need a GROUP BY clause.
Go to Top of Page

ddeme
Starting Member

3 Posts

Posted - 2014-01-23 : 23:24:22
thank you got the result.....:)
Go to Top of Page
   

- Advertisement -