Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to structure a SQL Select command
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01180237
Message ID:
01180245
Vues:
16
>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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform