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)
 How to select specific row from a Group?

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2013-04-28 : 12:24:12
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 - 2013-04-28 : 13:21:57
[code]
select project, [date], min(status) as status
from yourtable
group by project, [date]
[/code]
Go to Top of Page
   

- Advertisement -