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

phrankbooth
Posting Yak Master

USA
162 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

153 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  
 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.01 seconds. Powered By: Snitz Forums 2000