SELECT datename(month, TranDate) as เดือน,MONTH(TranDate) as เลขที่เดือน,YEAR(TranDate) as ปี , SUM(TranAmot) As TotalAmount FROM Tbl_Tran WHERE 1=1
GROUP BY datename(month, TranDate),MONTH(TranDate),YEAR(TranDate) ORDER BY MONTH(TranDate),YEAR(TranDate) ASC
Date :
2015-05-27 07:39:21
By :
billkyz5
No. 3
Guest
Code (SQL)
SELECT R.Fake, SUM(O.TranAmot) AS TotalAmount FROM Tbl_Tran O
RIGHT JOIN (SELECT 1 AS Fake UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5 UNION ALL
SELECT 6 UNION ALL
SELECT 7 UNION ALL
SELECT 8 UNION ALL
SELECT 9 UNION ALL
SELECT 10 UNION ALL
SELECT 11 UNION ALL
SELECT 12 ) R
ON R.Fake = MONTH(O.TranDate) AND YEAR(O.TranDate) = 2015
GROUP BY R.Fake