Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
i have a table like:a b c-----------1 280 a1 290 b1 210 c2 190 d2 199 e3 190 f3 160 gand i want a query with results like: a b c----------1 290 b2 199 e3 190 fso i need distinct values from column a, and the max value from column b.I've tried in differet ways, but no luck. Maybe someone can help me with an idea, how to start.Thanks
rockmoose
SQL Natt Alfen
3279 Posts
Posted - 2005-01-03 : 06:40:26
this is using a derived table:
select table.a, table.b, table.cfrom tablejoin (select a,max(b) as b from table group by a) maxb -- derived tableon table.a = maxb.aand table.b = maxb.b
rockmoose
kick_one
Starting Member
2 Posts
Posted - 2005-01-03 : 07:03:59
Thank you very muchI learned another thing :)I hope to learn more things here.