I have the following tables
TABLE: appointments
ID | PRICE | PAID 48 | 100 | 180
TABLE: appointments_product
select a.ID,a.PRICE,a.PAID,a.id as AppId, sum(b.total) as ProdTotal from appointments a INNER JOIN appointments_products b ON a.id = b.appointment_id group by a.ID,a.PRICE,a.PAID;