max value

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2006
Posts: 62
Reputation: Fenerbahce is an unknown quantity at this point 
Solved Threads: 0
Fenerbahce Fenerbahce is offline Offline
Junior Poster in Training

max value

 
0
  #1
Jan 11th, 2007
hi,

table : kisiler

name surname points
----- -------- ----
ali elli 1
ali elli 5
ali elli 5
veli kollu 3
veli kollu 4
adem bacakli 2
ali elli 4


how can i get reqult which has been shown below ? MAX value

ali elli 5
ali elli 5

thanks
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: max value

 
0
  #2
Jan 11th, 2007
not 100% sure what you are going for, but hopefully one of these will either do it for you or get you going in the right direction


1. this will give you each person and their max
  1. SELECT name,surname,max(points)AS mp FROM kisiler GROUP BY name,surname

2. this will give you each person and all instances of their max
  1. SELECT k.* FROM kisiler k
  2. INNER JOIN (SELECT name,surname,max(points)AS mp FROM kisiler GROUP BY name,surname) c
  3. ON c.name = k.name AND c.surname = k.surname AND k.points = c.mp

3. this will give you all instance of anyone who got the max points
  1. SELECT * FROM kisiler WHERE points = (SELECT max(points) FROM kisiler)

if you need more help let me know
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 62
Reputation: Fenerbahce is an unknown quantity at this point 
Solved Threads: 0
Fenerbahce Fenerbahce is offline Offline
Junior Poster in Training

Re: max value

 
0
  #3
Jan 11th, 2007
Thank you very very very much,

You realy give very important eamples. they will help me future.

Thank again.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: max value

 
0
  #4
Jan 11th, 2007
you're quite welcome
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC