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
 Other Forums
 MS Access
 SQL statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ktrkanjec
Starting Member

1 Posts

Posted - 08/05/2014 :  15:33:40  Show Profile  Reply with Quote
Hello,
need help,
from table with structure:
A1, B1, C1
A1, B2, C2
A1, B3, C3

I need SQL statement with result:

A1, max of B with appropriate C.

Thanks!

tkizer
Almighty SQL Goddess

USA
37287 Posts

Posted - 08/05/2014 :  15:51:27  Show Profile  Visit tkizer's Homepage  Reply with Quote
;with cte (column1, column2)
as
(select column1, max(column2) as column2 from @t1 group by column1)
select cte.column1, cte.column2, column3
from @t1 t
join cte
on t.column1 = cte.column1 and t.column2 = cte.column2


Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
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.03 seconds. Powered By: Snitz Forums 2000