Select empno,sum(cast(substring(othours,0,3)as float)) as
Hour,sum(cast(substring(othours,4,5)as float)) as Minutes from tmstrans
group by empno,othours
它顯示像以下請糾正我的查詢
- 1數據,10
- 1,30
- 2,10
- 2,30
我需要以下數據
- 1,40
- 2,40
請幫助
Select empno,sum(cast(substring(othours,0,3)as float)) as
Hour,sum(cast(substring(othours,4,5)as float)) as Minutes from tmstrans
group by empno,othours
它顯示像以下請糾正我的查詢
我需要以下數據
請幫助
假設你想SUM
兩個小時和分鐘列,你從GROUP BY
條款刪除othours
列。測試這樣的:
SELECT empno,
SUM(CAST(SUBSTRING(othours,0,3) AS float)) AS Hour,
SUM(CAST(SUBSTRING(othours,4,5) AS float)) AS Minutes
FROM tmstrans
GROUP BY empno
謝謝group'非常多,問題就解決了 –
@Asifkhan如果這是正確的,你應該接受的答案是:http://meta.stackexchange。 COM /問題/ 5234 /如何-不接受-的回答工作 –
刪除'othours'從'BY子句 – spencer7593