Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 summing all entries with same date

Author  Topic 

c.vaibhav
Starting Member

26 Posts

Posted - 2009-10-14 : 09:24:01
Hi friends,
I have a database which has multiple entries for the same date.

SQL tables doesnt have only date columns, there is only a datetime column so these entries though belong to the same date but have different times.

Hence when I use the sum function and I group them by date it still gives me two separate entries.

Can anyone help?

Regards,
Vaibhav

cipriani1984
Constraint Violating Yak Guru

304 Posts

Posted - 2009-10-14 : 09:26:25
Any chance of example data?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-10-14 : 09:26:40
[code]
select dateadd(day, datediff(day, 0, datecol), 0), sum(othercol)
from sometable
group by dateadd(day, datediff(day, 0, datecol), 0)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

c.vaibhav
Starting Member

26 Posts

Posted - 2009-10-15 : 01:49:13
Thanks alot!!!!
Go to Top of Page
   

- Advertisement -