Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subquery invalid
Message
From
23/11/2006 11:49:27
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01171586
Message ID:
01172092
Views:
17
That worked! Thanks. So far I have JOINED 8 of those derived tables. How many can I do?

Thanks again,

Yossi

>Not necessary. Here's an alternative that uses derived table (not tested)
>
>SELECT hi_flcode, SUM(hi_amt), ;
>		SumWldelvf, SumHddelvf  ;
>	FROM hatcinfo ;
>	JOIN ( ;
>			SELECT lm_flcode, SUM(lm_wldelvf) AS SumWldelvf, ;
>					SUM(lm_hddelvf) AS SumHddelvf FROM lotmast ;
>				WHERE SUBSTR(lm_flcode,5,4) <= lcFlockNumberEnd  ;
>					AND SUBSTR(lm_flcode,5,4) >= lcFlockNumberBegin  ;
>				GROUP BY lm_flcode ;	
>			) lm ON lm.lm_flcode = hi_flcode ;
>	WHERE SUBSTR(hi_flcode,5,4) <= lcFlockNumberEnd  ;
>		AND SUBSTR(hi_flcode,5,4) >= lcFlockNumberBegin  ;
>	GROUP BY hi_flcode ;
>	INTO CURSOR results
>
>>Thanks, Sergey. I guaess that means that I need to execute a subquery for each field I want.
>>
>>>A subquery in a field list can return only 1 value
>>>
...
>>>	(SELECT SUM(lm_wldelvf) FROM lotmast ;
>>>	WHERE lm_flcode = hi_flcode ) AS sum1,  ;
>>>	(SELECT SUM(lm_hddelvf) FROM lotmast ;
>>>	WHERE lm_flcode = hi_flcode ) AS Sum2 ;
>>>...
>>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform