Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Syntax for Subsetting
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00569737
Message ID:
00569746
Views:
19
>>I am trying to build a summary view based on a lot of status info.
>>In the original table, I have multiple rows with varying iQueueID values, and cStatusDesc can be any number of things. I just want the rows where there is only 1 entry and it is 'File added to the queue. Ready for processing'. In the original table, only 1 row satisfies this condition, but I seem to be getting that 1 row and also rows that have 'File added to the queue. Ready for processing' and other values as well.
>>
>>
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.' )
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform