[Solved] How create sum from tabel 2 and show data tabel 1 and tabel 2 [closed]
On MySQL 8+, we can handle this without a subquery by using analytic functions: SELECT b.id, a.invoice, b.price AS total, SUM(b.price) OVER (PARTITION BY a.id) AS count FROM TableB b LEFT JOIN TableA a ON a.id = b.aid; On earlier versions of MySQL, or if you are doing this from an ORM layer which doesn’t … Read more