Select Count(*) as iCount , iQueueID , 'Submitted' as cSummaryStatus >>from AppQueueStd >>Where cStatusDesc='File added to the queue. Ready for processing.' >>Group By iQueueID , cTPAID , cSubmittedBy , tCreateDt >>Having Count(*)=1>>
Select iQueueID , 'Submitted' as cSummaryStatus ; > from AppQueueStd ; > Where cStatusDesc='File added to the queue. Ready for processing.' ; > And iQueueID Not In ( ; > Select iQueueID ; > from AppQueueStd ; > Where cStatusDesc<>'File added to the queue. Ready for processing.' ) > >Or using correlated query ( it could be faster)
Select iQueueID , 'Submitted' as cSummaryStatus ; from AppQueueStd ; Where cStatusDesc='File added to the queue. Ready for processing.' ; And Not Exists ( ; Select iQueueID ; from AppQueueStd AQS ; Where AQS.iQueueID = AppQueueStd.iQueueID ; And AQS.cStatusDesc<>'File added to the queue. Ready for processing.' )