Hello. Threw an example for clarity. I tried to draw a detailed picture of what I want to get. But the problem is that the values ​​in the derivation of the 3 tables are duplicated. And it turns out the wrong amount! Here is an example + SQL query. enter image description here

SELECT Order.Id, Order.Customer, SUM(Order_position.Weight), SUM(Order_other.Price * Order_other.Value) FROM Order LEFT JOIN Order_position ON Order.Id = Order_position.Order_id LEFT JOIN Order_other ON Order.Id = Order_other.Order_id WHERE Order.Id = 1 

    1 answer 1

     SELECT O.Id, O.Customer, (select SUM(Weight) from Order_position where O.Id = Order_position.Order_id ) as Weight, (select SUM(Price * Value) from Order_other where O.Id = Order_other.Order_id) as Other FROM `Order` as O WHERE O.Id = 1 

    Option 2:

     SELECT A.Id, A.Customer, A.Weight, SUM(Order_other.Price * Order_other.Value) FROM ( SELECT O.Id, O.Customer, SUM(Order_position.Weight) as Weight FROM `Order` as O LEFT JOIN Order_position ON O.Id = Order_position.Order_id WHERE O.Id = 1 GROUP BY O.Id, O.Customer ) A LEFT JOIN Order_other ON A.Id = Order_other.Order_id GROUP BY A.Id, A.Customer, A.Weight 
    • one
      I chose option 1! Thank you - Alexander Rublev