我得到这些行的每日数据总和?
SELECT convert(varchar, okuma_tarihi, 102) as Gunler,SUM(toplam_kullanim_T1) as TotalUsageValue,'T1' as UsageType FROM TblSayacOkumalari
GROUP BY convert(varchar, okuma_tarihi, 102)
UNION ALL
SELECT convert(varchar, okuma_tarihi, 102) as Gunler,SUM(toplam_kullanim_T2) as TotalUsageValue,'T2' as UsageType FROM TblSayacOkumalari
GROUP BY convert(varchar, okuma_tarihi, 102)
UNION ALL
SELECT convert(varchar, okuma_tarihi, 102) as Gunler,SUM(toplam_kullanim_T3) as TotalUsageValue,'T3' as UsageType FROM TblSayacOkumalari
GROUP BY convert(varchar, okuma_tarihi, 102)
如何每周或每月获得数据总和?有没有关于这个主题或代码示例的教程?当我写MONTH(DATE)
而不是convert(varchar, okuma_tarihi, 102)
它显示时,例如该月的所有数据总和。(2010 年 6 月值 + 2011 年 6 月值)。我不想要这个。我使用 MSSQL Server 2008。
谢谢。