Home > Software engineering >  Online for an SQL statement
Online for an SQL statement

Time:10-19

Table 1
Time type amount
1 of 1000
2 of 1600
Table 2
Time type amount
1 500
2 500
Table 3
Time type amount
1 put 100
2 the trip 500

Now want to use an SQL statement, calculate the amount of table 1 and table 2 amount and reduction amount in table 3

I'm using the ACCESS database

CodePudding user response:

 
Select a.s - b.s - c.s. as s1 from (select sum (amount) as a s the from table) as a, (select sum (amount) as s from table 2) as b, (select sum (amount) as s from table 3) as c

CodePudding user response:

Amount - select a. b. - c. payable amount as
From table 1 a
The join table 2 b on a. time=b.
Time=the join table 3 c on a. c. time

CodePudding user response:

refer to the second floor caozhy response:
select a. amount - the amount - c. b. amount as
From table 1 a
The join table 2 b on a. time=b.
The join table 3 c on a. time=c.

The elder brothers I didn't look but coarse took one look at you write wrong, what is the relationship between time is not necessarily equal, you take time to dry hair?
I think is the right 1 #, 1/f is not correct I scold the building

CodePudding user response:

Given type fields, 3 tables can be in 1.
  • Related