Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can I do this SQL Select in 1 step?
Message
 
 
To
16/06/2002 17:39:50
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00669031
Message ID:
00669053
Views:
20
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform