---------------colete--------------------
| id | id_comanda | status | id_lista |
----------------------------------------
| | 21775 | 0 | 3820 |
----------------------------------------
| | 21776 | 0 | 3820 |
----------------------------------------
| | 21777 | 0 | 3820 |
----------------------------------------
-----comenzi--------
| id | taxComanda |
--------------------
|21775| 16.00 |
--------------------
|21776| 00.00 |
--------------------
|21777| 16.00 |
--------------------
I want to get SUM from column taxaComand from table comenzi by making the selection from column id_lista from table colete, so the SUM at the end to be 32.00
This is what i have, but is not good.:
SELECT a.id_comnda AS a_id_comanda, a.id_lista AS a_id_lista,
b.id AS b_id, b.taxaComanda AS b_taxaComanda
(SELECT sum(taxaComanda) FROM comenzi WHERE b.id = a.id_comanda AS totalTaxaComanda)
FROM colete a
INNER JOIN comenzi b ON b.id = a.id_comanda
WHERE a.id_lista = 3820
GROUP BY a.id_comanda