Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to solve this SQL Select?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01099608
Message ID:
01099667
Views:
19
>>Oops,
>>my mistake. I didn't realise you joined the two other tables by one field in your main table.
>>:-(
>
>No problem at all. You are trying to help and I appreciate it very much. The good thing is that my problem is not just of my making <g>.
CREATE TABLE Main (Id I)
INSERT INTO Main VALUES (1)
INSERT INTO Main (Id) VALUES (1)
INSERT INTO Main (Id) VALUES (2)

CREATE TABLE Tbl2 (PK I, SumV N(10,2))
INSERT INTO Tbl2 VALUES (2,200)

CREATE TABLE Tbl3 (PK I, SumV N(10,2))
INSERT INTO Tbl3 VALUES (1,200)
INSERT INTO Tbl3 VALUES (1,400)

SELECT Id, (SELECT SUM(SumV) FROM Tbl2 WHERE Tbl2.Pk = Main.Id) AS Sum2,;
           (SELECT SUM(SumV) FROM Tbl3 WHERE Tbl3.Pk = Main.Id) AS Sum3;
FROM Main;
GROUP BY Id;
INTO CURSOR test
BROWSE NORMAL
:-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform