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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -