Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to simplify sql commands
Message
From
24/01/2000 16:59:21
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00320611
Message ID:
00321847
Views:
18
>>The table has three fields which I am concerned with.
>>ProjectStatus
>>TalentId
>>Date
>>
>>There can be multiple records of the same TalentId. I want to in one SQL statement get the most recent ProjectStatus by looking at the date and be able to filter the ProjectStatus based on user input. I know this can be done in two steps. I want to know if there is a clean way of doing that in one.
>>
>>We've thought of concatenating TalentId and Date and using a sub-select but I was hoping for a cleaner way of handling that.
>
>
>SELECT TOP 1 Date,ProjectStatus,TalentId ;
>       FROM yourtable ;
>       WHERE ProjectStatus=userinputvalue ;
>       ORDER BY 1 DESC ;
>       INTO CURSOR latest
>
I am only getting one record.

Here's the code
* lcList is a comma delimited list of use selections.

SELECT TOP 1 ItemDate, TalentId, cItemType ;
     FROM vItemTal ;
     WHERE INLIST( vItemTal.cItemType, &lcList )
     ORDER BY 1 DESC ;
     GROUP BY 2
     INTO CURSOR currParent
I've tried it without the GROUP BY with the same results. The view vItemTal is a concatenation of a talent and an appointment record. The only way to determine what the cItemType ( status - excuse the naming convetions. This is an inherited project ), is to find what the most recent appointment record and determine what the status is in that record. There is no status in the talent record.

Then we can filter once we've determined what the "status" is.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform