Помогите с запросом, пожалуйста. Есть такая таблица с весом материалов (их 5), каждому материалу присвоен id 1-5, нужно составить таблицу по сумме материалов за промежуток времени
select sum(case when id_material=1) then VAL else 0) as MAT1 sum(case when id_material=2) then VAL else 0) as MAT2 sum(case when id_material=3) then VAL else 0) as MAT3 sum(case when id_material=4) then VAL else 0) as MAT4 sum(case when id_material=5) then VAL else 0) as MAT5 from .... where id_material in (1,2,3,4,5)