Reputation: 241
I have following table.
How can I be able to count per month (since 2014 until 2016) with earnings?
Upvotes: 0
Views: 106
Reputation: 1008
If I correctly understand your question you need just add sum of earnings and year group.
Try this:
SELECT
COUNT(*) as test,
SUM(EarnValue) as Total,
YEAR(TxnDate) as Year,
MONTH(TxnDate) as Month
FROM fschevrondata
WHERE
YEAR(TxnDate) >= 2014 -- or this can be TxnDate >= '2014-01-01'
AND YEAR(TxnDate) <= 2016 -- or this can be TxnDate <= '2016-12-31'
GROUP BY
YEAR(TxnDate),
MONTH(TxnDate)
Upvotes: 1