谁能帮忙看看这个过滤要怎样弄,前面的月份是SQL整出来的 SELECT distinct i_plc_zutai.ztName,code, SUM(CASE WHEN MONTH(gatherDate) =1 THEN DiffData ELSE 0 END) 一月, SUM(CASE WHEN MONTH(gatherDate) =2 THEN DiffData ELSE 0 END) 二月, SUM(CASE WHEN MONTH(gatherDate) =3 THEN DiffData ELSE 0 END) 三月, SUM(CASE WHEN MONTH(gatherDate) =4 THEN DiffData ELSE 0 END) 四月, SUM(CASE WHEN MONTH(gatherDate) =5 THEN DiffData ELSE 0 END) 五月, SUM(CASE WHEN MONTH(gatherDate) =6 THEN DiffData ELSE 0 END) 六月, SUM(CASE WHEN MONTH(gatherDate) =7 THEN DiffData ELSE 0 END) 七月, SUM(CASE WHEN MONTH(gatherDate) =8 THEN DiffData ELSE 0 END) 八月, SUM(CASE WHEN MONTH(gatherDate) =9 THEN DiffData ELSE 0 END) 九月, SUM(CASE WHEN MONTH(gatherDate) =10 THEN DiffData ELSE 0 END) 十月, SUM(CASE WHEN MONTH(gatherDate) =11 THEN DiffData ELSE 0 END) 十一月, SUM(CASE WHEN MONTH(gatherDate) =12 THEN DiffData ELSE 0 END) 十二月, year(i_plc_equipment1summary.gatherDate) as 年, month(i_plc_equipment1summary.gatherDate) as 月, i_plc_equipment1summary.DiffData,i_plc_equipment1summary.operationValue FROM i_plc_zutai,i_plc_machine,i_plc_equipment1summary,i_plc_gateinfo WHERE i_plc_gateinfo.ztID=i_plc_zutai.id and i_plc_zutai.id=i_plc_machine.ztID and i_plc_machine.id=i_plc_equipment1summary.DeviceID and i_plc_equipment1summary.operationValue='产能' GROUP BY MONTH(gatherDate) |
最佳回答 |
||||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|