我有一个包含以下架构的viewtable:
No_quotation |period |total_hour
001/QY-RKS/05/2016 Mar-16 21.0
001/QY-RKS/05/2016 Mar-16 21.0
002/QY-RKS/05/2016 Apr-16 18.0
002/QY-RKS/05/2016 Apr-16 18.0
我需要像这样总结表
No_quotation |period |total_hour
001/QY-RKS/05/2016 Mar-16 42.0
002/QY-RKS/05/2016 Apr-16 36.0
答案 0 :(得分:0)
您只需对每个total_hour
/ No_quotation
群组period
列进行汇总:
SELECT No_quotation, period, SUM(total_hour) AS total_hour
FROM viewtable
GROUP BY No_quotation, period