SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 reduce a query to only one row
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

129 Posts

Posted - 09/25/2013 :  16:55:26  Show Profile  Reply with Quote
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

Almighty SQL Goddess

38073 Posts

Posted - 09/25/2013 :  17:17:23  Show Profile  Visit tkizer's Homepage  Reply with Quote
select id, max(fast) as fast, max(strong) as strong
from yourtable
group by id

Tara Kizer
SQL Server MVP since 2007
Go to Top of Page

Posting Yak Master

129 Posts

Posted - 09/25/2013 :  17:26:01  Show Profile  Reply with Quote
thanks you tkizer
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.05 seconds. Powered By: Snitz Forums 2000