SELECT i.institution_name,sum(m.material_price) as 'price'
from disbursementing d
inner join disbursement_list dl on d.disbursementing_number = dl.disbursementing_number
inner join material m on m.material_number = m.material_number
inner join personnel p on p.personnel_number = d.personnel_number_disbursementing
inner join institution i on i.institution_number = p.institution_number
where d.disbursement_status = 1
group by i.institution_name
SELECT i.institution_name,sum(m.material_price) as 'price'
from disbursementing d
inner join disbursement_list dl on d.disbursementing_number = dl.disbursementing_number
inner join material m on m.material_number = m.material_number # บันทัดนี้มีไว้ทำไม table เดียวกัน field เดียวกัน
inner join personnel p on p.personnel_number = d.personnel_number_disbursementing
inner join institution i on i.institution_number = p.institution_number
where d.disbursement_status = 1
group by i.institution_name
SELECT i.institution_name,sum(m.material_price) as 'price'
sum คือการบวก แน่ใจไหมว่า ต้องการบวก