Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2012
    Posts
    1

    Unanswered: Help in finding a count of columns...

    First of all, thanks for the help. My question is this: I have a query that returns the total number of wins for a baseball team in the 1998 season in the AL division. It is the following.
    Code:
    SELECT name as teamName, W as Wins
    FROM teams
    WHERE yearID = '1998' AND lgID = 'AL'
    group by name
    ORDER BY W DESC
    This works fantastic. However, I would like to select on a 3rd column, which we will call 'Rank'. It needs to return a ranking for the results. The team with the highest wins is ranked #1, and so on down the list. The best way to do this would be to see how many teams have the same or more wins than me. This will give the top team a ranking of 1, etc. Could anyone help me figure out how to do this? Thanks.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    consider using the COUNT() function
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •