Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

asifbhura
Posting Yak Master

India
165 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
6065 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
169 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  
 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.11 seconds. Powered By: Snitz Forums 2000