PDA

View Full Version : Quick SQL question


LeTenken
December 28th, 2007, 06:46 PM
I am not too familiar with SQL, any help will be appreciated.
Lets say I wrote a select statement that returned something like this:

Name x y
Bob 1 2
Bob 3 5
Bob 10 10
Frank 1 3
Chris 2 2
Chris 2 3

how would i narrow my query down to only one instance of Bob and Chris where x+y is the largest total?
i hope to get a new query that will make this output:

Name x y
Bob 10 10
Frank 1 3
Chris 2 3


please let me know if i should include any additional information.

LeTenken
December 28th, 2007, 07:23 PM
nevermind, used DISTINCTROW

anbumanij
December 29th, 2007, 01:01 AM
Hi goody,

select name,max(x),max(y) from name group by name;

Use this query this might very well solve your problem...





Keep going ........... :guitar: