Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
0 or More Children recs. but need SQL for NULL or first
Message
From
23/03/2007 09:58:05
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01205365
Message ID:
01207628
Views:
26
>Hi Fabio
>
>Thanks for your replies. The query you suggested still raises the error:
>SQL: Queries of this type are not supported.
>
>If I remove the ORDER BY in the subquery I get:
>SQL: TOP requires an ORDER BY.
>
>Now I remove the TOP 1 in the subquery and I get:
>Subquery returned more than one record.
>
>I just put back in the ORDER BY in the subquery again:
>SQL: The ORDER BY clause is invalid in subqueries, unless TOP is also specified.
>
>I put back the TOP 1 also in the subquery and we are back to the original error:
>SQL: Queries of this type are not supported.
>
>I have tried this with engine behavior 70 and 90.
>
>I also need to then later join the iPartyID from the subquery with the master table containing the name of the party.
>
>What am I missing. Please advise.
>

fix a error, try this
SELECT  TD.*, ;
		mLookup.cValue AS cLevel1, ;
		mLookup_A.cValue AS cLevel2, ;
		mLookup_B.cValue AS cLevel3, ;
		(SELECT TOP 1 iPartyID ;
			FROM VSO3!sDocsParty SDP ;
			WHERE iPID = TD.iID ;
			ORDER BY iPID) AS iPartyID ;
	FROM VSO3!tDocs  TD ;
		LEFT JOIN VSO3!mLookup ;
				ON TD.ILvl1ID = mLookup.iID ;
		LEFT JOIN VSO3!mLookup mLookup_A ;
				ON TD.ILvl2ID = mLookup_A.iID ;
		LEFT JOIN VSO3!mLookup mLookup_B ;
				ON TD.ILvl3ID = mLookup_B.iID ;
	ORDER BY mLookup.cValue, mLookup_A.cValue, mLookup_B.cValue
>>
>>SELECT  TD.*, ;
>>		mLookup.cValue AS cLevel1, ;
>>		mLookup_A.cValue AS cLevel2, ;
>>		mLookup_B.cValue AS cLevel3, ;
>>		(SELECT TOP 1 iPartyID ;
>>			FROM VSO3!sDocsParty SDP ;
>>			WHERE iPID = TD.iID ;
>>			ORDER BY iID) AS iPartyID ;
>>	FROM VSO3!tDocs  TD ;
>>		LEFT JOIN VSO3!mLookup ;
>>				ON TD.ILvl1ID = mLookup.iID ;
>>		LEFT JOIN VSO3!mLookup mLookup_A ;
>>				ON TD.ILvl2ID = mLookup_A.iID ;
>>		LEFT JOIN VSO3!mLookup mLookup_B ;
>>				ON TD.ILvl3ID = mLookup_B.iID ;
>>	ORDER BY mLookup.cValue, mLookup_A.cValue, mLookup_B.cValue
>>
>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform