I have the following tables
TABLE: appointments
ID | PRICE | PAID 48 | 100 | 180
TABLE: appointments_product
Use where to check if price is equal to paid and the use group by to group with appointment_id.