SQL Server Adding summing values based on the month -


i have table has following 2 columns: date , price

i want sum prices based on same month of same year. have:

2012-07-27 00:00:00.000 0 2012-07-27 00:00:00.000 15000 2012-08-27 00:00:00.000 0 2012-08-27 00:00:00.000 12000 2012-09-28 00:00:00.000 1000 2012-09-28 00:00:00.000 9000 2012-10-26 00:00:00.000 0 

i want following:

2012-07-27 00:00:00.000 15000 2012-08-27 00:00:00.000 12000 2012-09-28 00:00:00.000 10000 2012-10-26 00:00:00.000 0 

thank you.

you desired result given sample data , output with:

select date, sum(price) yourtable group date order date 

if had multiple dates in month , wanted return each distinct date still show monthly sum each record use:

select date, sum(sum(price)) on (partition year(date),month(date)) yourtable group date order date 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -