Reputation: 1181
I have a SQL query which basically looks like this:
select t1.Date,t1.Earnings
from table1 as t1
So the query result is as following:
5.5.2015 20.0
5.5.2015 16.0
5.5.2015 24.0
6.6.2015 15.0
6.6.2015 15.0
My question is: is there any way to merge these 3 dates into one(as they are same basically) and merge these numerical values so that the result would look like this:
5.5.2015 70.0
6.6.2015 30.0
Only those records with same date should be merged.
Can someone help me out with this please? Thanks!
Upvotes: 0
Views: 92
Reputation: 1952
This should work.
SELECT t1.Date, SUM(T1.Earnings)
FROM table1 as t1
GROUP BY Date
If, however, your dates are stored as DATETIME
and the time portions do not match, you'll need to cast them to DATE
in order to get the grouping correct:
SELECT CAST(t1.Date AS DATE) Date, SUM(t1.Earnings)
FROM table1 as t1
GROUP BY CAST(t1.Date AS DATE)
Upvotes: 2