Jump to content

Newbie question about selecting a single data entry


JohnJSal

Recommended Posts

Hi everyone. I have a question which seems like it should be painfully easy to answer, but I can't figure it out. I've tried several different queries, and they either return too much information, or they don't work.

Here's the situation: I'm using a baseball database and am working with a single table called Batting. What I'd like to do is display the playerID and RBI columns for the player with the most RBIs in the 2005 (yearID). I've tried combinations of max(RBI) and playerID, but then I have to use a GROUP BY clause, which displays more than I want.

So I'm hoping someone can help me. This seems like a very basic thing to do, but I'm having trouble working with a 'normal' column like playerID and an aggregate like max(RBI).

Thanks,
John
[quote author=AndyB link=topic=106273.msg424797#msg424797 date=1156953145]
SELECT playerID, RBI from Batting WHERE yearID = '2005' ORDER by RBI DESC LIMIT 1
[/quote]

Hmm, interesting! I guess I was on the wrong track with max(RBI). Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.