问题和表的样式都在图上
select id 订单编号, pandetailid 班次, sum(planamount) 计划产量, sum(realamount) 实际产量 from dbo.tb_pp_plandetail group by id,pandetailid
sql语句最后加上
where PlanDetailId = "${班次}"
参数名“班次”可任意修改,建议用英文