SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to do ASC and DESC in SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 01/22/2014 :  16:04:20  Show Profile  Reply with Quote
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

Almighty SQL Goddess

38073 Posts

Posted - 01/22/2014 :  16:28:20  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
Go to Top of Page

Starting Member

3 Posts

Posted - 01/22/2014 :  16:45:19  Show Profile  Reply with Quote
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

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 01/22/2014 :  18:12:20  Show Profile  Reply with Quote
You need a GROUP BY clause.
Go to Top of Page

Starting Member

3 Posts

Posted - 01/23/2014 :  23:24:22  Show Profile  Reply with Quote
thank you got the result.....:)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000