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

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to disctinct duplicate with max grade
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

asifbhura
Posting Yak Master

India
164 Posts

Posted - 09/06/2013 :  16:30:39  Show Profile  Reply with Quote
Hello...

I have records as below

std_name std_id Grade
ABC 456 7 - A
ABC 456 8 - B
XYZ 568 2 - C
XYZ 568 5 - D

I want to distinct with std_code and max with grade like below


std_name std_id Grade
ABC 456 8 - B
XYZ 568 5 - D

TG
Flowing Fount of Yak Knowledge

USA
5932 Posts

Posted - 09/06/2013 :  17:21:34  Show Profile  Reply with Quote
select std_name, std_id, max(Grade) Grade from <yourTable> group by std_name, std_id

Be One with the Optimizer
TG
Go to Top of Page

VeeranjaneyuluAnnapureddy
Posting Yak Master

India
158 Posts

Posted - 09/10/2013 :  05:06:50  Show Profile  Reply with Quote
quote:
Originally posted by TG

select std_name, std_id, max(Grade) Grade from <yourTable> group by std_name, std_id

Be One with the Optimizer
TG



veeranjaneyulu
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.42 seconds. Powered By: Snitz Forums 2000