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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 reduce a query to only one row

Author  Topic 

sebastian11c
Posting Yak Master

129 Posts

Posted - 2013-09-25 : 16:55:26
hi there,, one more time i need your help.


i have a query that returns a table something like this

visit_number id fast strong
1 12 5 7
2 12 4 9
3 12 6 3

and i want to reduce to only one row with the max value from columns "fast" , "strong"


id fast strong
12 6 9



i hope someone can help me


many thanks in advanced

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-09-25 : 17:17:23
select id, max(fast) as fast, max(strong) as strong
from yourtable
group by id

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

sebastian11c
Posting Yak Master

129 Posts

Posted - 2013-09-25 : 17:26:01
thanks you tkizer
Go to Top of Page
   

- Advertisement -