Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to structure a SQL Select command
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01180237
Message ID:
01180245
Views:
15
>I have a situation where a record represents a piece of art being created. It can go through various phases (request, initial completion, client approval, etc.) and may repeat some. So there is a child table that holds the task/phase, when it was assigned, and who assigned it. There is an index on the date/time field set up as descending so that the latest task/phase is always at the top. I need to select records whose current task/phase is a certain task/phase. It's easy enough to select records with this task/phase, but is there syntax that will let me select records where a particular task/phase is the most recent task/phase for that record? I can do this with a SQL statement and some iterative programming, but I was wondering about getting it done in one SQL statement.

Hi Russell,

Try (not tested)
SELECT *
  FROM mytable mt1
  WHERE task = lcTask
    AND NOT EXISTS ( SELECT * FROM mytable 
 		       WHERE ArtID = mt1.ArtID 
			 AND date > mt1.date)
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform