Will doing INNER JOINs work when the two child tables will have differnt number or records? For 1 qn_head record, there may be 5 qn_dtl records, and 3 qn_inv records. When I tried doing joins in SQL Server, it got confused and summed the wrong number of rows. I'll try it and see what I get. I'll let you know. :)
-----
Lee Perkins
>You're correct in that VFP doesn't support sub-queries of this type. (I think VFP 9 will, but that won't be out for a while.) Here's how you need to do this:
>
>SELECT h.pid_owner, h.ord_cod, ;
> SUM(d.itm_prcus * d.qty_ord) as OrderTotal, ;
> SUM(i.itm_prcus * i.qty_sent) as InvoiceTotal ;
> FROM C:\QN\datatmp\qn_head h ;
> INNER JOIN C:\qn\datatemp\qn_dtl d ;
> ON d.pid_owner = h.pid_owner AND d.ord_cod = h.ord_code ;
> INNER JOIN c:\qn\datatemp\qn_inv i ;
> ON i.pid_owner = h.pid_owner AND i.ord_code = h.ord_cod ;
> ORDER BY h.pid_owner, h.ord_cod
>
-----
Lee Perkins
TigerBase Technologies
"Lee is one that would plug his brain into the internet, if he could, and STILL scream for more" - Very good friend of Lee's