select 大项目号,大项目名称,小项目号,车间编号,车间名称,班组编号,班组名称,type,sum(工时)/60 班组总工时 from( SELECT HRGROUPWORKHOURS.PRNAME_S 小项目名称, HRGROUPWORKHOURS.PRNAME 大项目名称, HRGROUPWORKHOURS.PRCODE_S 小项目号, HRGROUPWORKHOURS.PRCODE 大项目号, BSWORKCENTER.BSWORKSHOP_CODE 车间编号, BSWORKCENTER.BSWORKSHOP_NAME 车间名称, BSWORKCENTER.CODE 班组编号, BSWORKCENTER.NAME 班组名称, HRGROUPWORKHOURS.DATE 日期, SUM(HRGROUPWORKHOURS.HOURS) 工时, HRGROUPWORKHOURS.TYPE FROM HRGROUPWORKHOURS LEFT JOIN BSWORKCENTER ON BSWORKCENTER.GUID = HRGROUPWORKHOURS.BSWORKCENTER_GUID WHERE (HRGROUPWORKHOURS.DATE> ='2023-4-25' and HRGROUPWORKHOURS.DATE<= '2023-5-24' ) and HRGROUPWORKHOURS.PRCODE is not NULL GROUP BY HRGROUPWORKHOURS.PRNAME_S , HRGROUPWORKHOURS.PRNAME , HRGROUPWORKHOURS.PRCODE_S , HRGROUPWORKHOURS.PRCODE , HRGROUPWORKHOURS.DATE , HRGROUPWORKHOURS.BSWORKCENTER_GUID , BSWORKCENTER.BSWORKSHOP_CODE , BSWORKCENTER.BSWORKSHOP_NAME , BSWORKCENTER.CODE , BSWORKCENTER.NAME , BSWORKCENTER.BSWORKSHOP_GUID, HRGROUPWORKHOURS.TYPE ) a GROUP BY 班组编号, 班组名称,大项目号,大项目名称,小项目号,车间编号,车间名称,type ORDER BY 大项目号,小项目号,班组编号,type 想把HRGROUPWORKHOURS.TYPE这个的查询结果0变成报工,1变成调整
时间: 2024-03-05 17:53:47 浏览: 70
你可以尝试使用CASE语句将HRGROUPWORKHOURS.TYPE的值转换为"报工"或"调整",例如:
```
SELECT 大项目号,大项目名称,小项目号,车间编号,车间名称,班组编号,班组名称,
CASE HRGROUPWORKHOURS.TYPE
WHEN 0 THEN '报工'
WHEN 1 THEN '调整'
ELSE HRGROUPWORKHOURS.TYPE
END as 类型,
SUM(工时)/60 班组总工时
FROM (
SELECT HRGROUPWORKHOURS.PRNAME_S 小项目名称, HRGROUPWORKHOURS.PRNAME 大项目名称,
HRGROUPWORKHOURS.PRCODE_S 小项目号, HRGROUPWORKHOURS.PRCODE 大项目号,
BSWORKCENTER.BSWORKSHOP_CODE 车间编号, BSWORKCENTER.BSWORKSHOP_NAME 车间名称,
BSWORKCENTER.CODE 班组编号, BSWORKCENTER.NAME 班组名称, HRGROUPWORKHOURS.DATE 日期,
SUM(HRGROUPWORKHOURS.HOURS) 工时, HRGROUPWORKHOURS.TYPE
FROM HRGROUPWORKHOURS
LEFT JOIN BSWORKCENTER ON BSWORKCENTER.GUID = HRGROUPWORKHOURS.BSWORKCENTER_GUID
WHERE (HRGROUPWORKHOURS.DATE>='2023-4-25' and HRGROUPWORKHOURS.DATE<='2023-5-24')
AND HRGROUPWORKHOURS.PRCODE IS NOT NULL
GROUP BY HRGROUPWORKHOURS.PRNAME_S, HRGROUPWORKHOURS.PRNAME, HRGROUPWORKHOURS.PRCODE_S,
HRGROUPWORKHOURS.PRCODE, HRGROUPWORKHOURS.DATE, HRGROUPWORKHOURS.BSWORKCENTER_GUID,
BSWORKCENTER.BSWORKSHOP_CODE, BSWORKCENTER.BSWORKSHOP_NAME, BSWORKCENTER.CODE,
BSWORKCENTER.NAME, BSWORKCENTER.BSWORKSHOP_GUID, HRGROUPWORKHOURS.TYPE) a
GROUP BY 班组编号, 班组名称,大项目号,大项目名称,小项目号,车间编号,车间名称,类型
ORDER BY 大项目号,小项目号,班组编号,类型
```
这样,查询结果中HRGROUPWORKHOURS.TYPE的值为0的将会显示为"报工",值为1的将会显示为"调整",其他值保持不变。
阅读全文