Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Quandary
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
SQL Quandary
Miscellaneous
Thread ID:
00817073
Message ID:
00817073
Views:
62
Who can explain this/help us get the right results? We are trying to get the sums of the values from the two children - but the return set brings back more than expected. If you take off the sums and group by's you can see what is being returned.
Same in vfp6,7,8 and SQL Server
CREATE CURSOR __parent (ipkey i)
APPEND BLANK
replace ipkey WITH 001

CREATE CURSOR __child1 (ifk i, namount1 n(10))
APPEND BLANK
replace ifk WITH 001
replace namount1 WITH 1000

APPEND BLANK
replace ifk WITH 001
replace namount1 WITH 1000


CREATE CURSOR __child2 (ifk i, namount2 n(10))
APPEND BLANK
replace ifk WITH 001
replace namount2 WITH 2000

APPEND BLANK
replace ifk WITH 001
replace namount2 WITH 2000

APPEND BLANK
replace ifk WITH 001
replace namount2 WITH 2000

SELECT sum(__child1.namount1) as __c1, sum(__child2.namount2) as __c2;
FROM __parent;
left OUTER JOIN __child1 ON __parent.ipkey = __child1.ifk;
left OUTER JOIN __child2 ON __parent.ipkey = __child2.ifk;
GROUP BY __parent.ipkey
Wayne Myers, MCSD
Senior Consultant
Forte' Incorporated
"The only things you can take to heaven are those which you give away" Author Unknown
Next
Reply
Map
View

Click here to load this message in the networking platform