A1
A2
A3
Three tables now I'm writing the words
Select A1.*,sum (A2.money) as money from A1 left joins A2 on A1.id=a2.id left joins A3 on a2.no = A3.no GROUP by a1.id;
The result is
Due to other factors must be connected to the A3 table, resulting in Money 35, I want Money to 25, how should I write?
Reply to discussion (solution)
A3.no not unique, resulting in a2.no=a3.no when A2 (11 1 10.00) appears two times
So you need to constrain the A3.
A3.no not unique, resulting in a2.no=a3.no when A2 (11 1 10.00) appears two times
So you need to constrain the A3.
Yes, I thought there is any way to solve, it seems that can not be linked to the list looked.
If written
Select A1.name,
(select SUM (count) from A3 where no in (select No from a2 where id = a1.id)) as Count,
SUM (A2.money) as money
From A1 left join A2 on a1.id=a2.id Group by A1.id;
The result is
But I want money, minus count, what should I write?
25-400
20-200