Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper syntax for creating sub-queries
Message
 
 
To
31/07/2008 11:40:30
Raza Malik
Universal Accounting Software
Edgewater, New Jersey, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01334260
Message ID:
01335560
Views:
12
Use TEXT ENDTEXT to create a SQL String, it would be easier to debug and execute.
text to lcSQL NOSHOW
SELECT po_d.rcv_numb, po_d.por_numb, po_d.ven_numb, po_d.usr_code, cTemp.nRcv_totl 
	FROM (SELECT po_d.rcv_numb, 
         SUM(po_d.por_txam + po_d.por_ntam) as nRcv_totl 
        FROM po_d GROUP BY po_d.rcv_numb) cTemp 
        INNER JOIN po_d ON cTemp.rcv_numb = po_d.rcv_numb
        ORDER BY po_d.rcv_numb 
ENDTEXT
chrtran(lcSQL, chr(10)+chr(13)," ")
&lcSQl
BTW, why do you need MAX(you key) as Primary Key? I think this would give you the problem.

>Hi Michel...
>
>As per you advice, I tried you code. It worked in a simple test. But the following code gave me a syntax error. Could you please look @ it and tell me where I am going wrong...
>
>
>CLOSE ALL
>DO PATH
>lcSql = "SELECT po_d.rcv_numb, po_d.por_numb, po_d.ven_numb, po_d.usr_code, cTemp.nRcv_totl "+;
>	"FROM (SELECT po_d.rcv_numb, MAX(po_d.rcv_numb) AS PrimaryKey, SUM(po_d.por_txam + po_d.por_ntam) AS nRcv_totl "+;
>        "FROM po_d GROUP BY po_d.rcv_numb) AS cTemp "+;
>		"INNER JOIN po_d ON (cTemp.rcv_numb = po_d.rcv_numb) "+;
>		"ORDER BY po_d.rcv_numb "
>
>lnRtnValue = SQLEXEC(gnC, lcSQL, "cPo_d")
>
>
>
>Thank You...
>
>Raza Malik
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform