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
 Other Forums
 MS Access
 SQL statement
 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
38200 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  
 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.02 seconds. Powered By: Snitz Forums 2000