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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to select specific row from a Group?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

phrankbooth
Posting Yak Master

USA
161 Posts

Posted - 04/28/2013 :  12:24:12  Show Profile  Reply with Quote
Hi,

From the table below, if Project.Date group has a Fail and Success, I'd like to keep the Fail row, but if single row (like the rest,) then keep that row regardless of Status.

Project|Date|Status
HLM|20130422|Fail <<if Success and Fail in same date, Keep Fail
HLM|20130422|Success
HLM|20130423|Fail
HLM|20130424|Success
HLM|20130425|Fail
HLM|20130426|Success

Thanks!

--PhB

singularity
Posting Yak Master

152 Posts

Posted - 04/28/2013 :  13:21:57  Show Profile  Reply with Quote

select project, [date], min(status) as status
from yourtable
group by project, [date]
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.09 seconds. Powered By: Snitz Forums 2000