Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can I do this SQL Select in 1 step?
Message
 
 
À
16/06/2002 17:39:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00669031
Message ID:
00669053
Vues:
18
What you're tring to acomplish? I'm not sure what is your definiton of 'steps' for a query and why it's so importent that there was only one step in a query. Anyway, following query uses correlated subquery.
SELECT * FROM t1 ;
	WHERE EffectiveDate IN ( ;
		SELECT max(EffectiveDate) ;
  from t1 t1_2 ;
  where EffectiveDate <= ?dParam ;
  	AND t1_2.Empid = t1.empid ) 
>Hi Sergey,
>This is still 2 steps, just combined onto 1 line of code.
>I was really hoping for something that would only "use t1 shared" once during the process.
>This is probably the best that can be done, but I'm still hoping.
>
>
>>This query should work
SELECT * FROM t1 ;
>>	WHERE STR(EmpId) + Dtos(EffectiveDate) IN ( ;
>>		Select Str(EmpID) + Dtos(max(EffectiveDate)) ;
>>  from t1 ;
>>  where EffectiveDate <= ?dParam ;
>>  group by EmpID )
>>
>>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform