Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have a table that has a column date and value, what I need is to sum a value showing just one date column. Ex: I have this:
date value 2018-01-01 150 2018-01-23 140
what I need:
date sum(value) 2018-01 290
2018-03-14
Simple solution to get sums per month:
SELECT to_char(date, 'YYYY-MM') AS mon, sum(value) AS sum_value FROM tbl GROUP BY 1;
For large tables it's cheaper to group on date_trunc('month', date) instead.
date_trunc('month', date)
Related:
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
2018-03-14?