sql server - Merging two or more records in SQL query result with same dates -
i have sql query looks this:
select t1.date,t1.earnings table1 t1
so query result 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: there way merge these 3 dates one(as same basically) , merge these numerical values result this:
5.5.2015 70.0 6.6.2015 30.0
only records same date should merged.
can me out please? thanks!
this should work.
select t1.date, sum(t1.earnings) table1 t1 group date
if, however, dates stored datetime
, time portions not match, you'll need cast them date
in order grouping correct:
select cast(t1.date date) date, sum(t1.earnings) table1 t1 group cast(t1.date date)
Comments
Post a Comment