pal3
pal3

Reputation: 241

Transaction count per month (since 2014 until 2016)

I have following table.
How can I be able to count per month (since 2014 until 2016) with earnings?

transactions

Upvotes: 0

Views: 106

Answers (1)

fofik
fofik

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

Related Questions