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
 Development Tools
 Other Development Tools
 Total money field in search resull

Author  Topic 

haibec
Yak Posting Veteran

54 Posts

Posted - 2008-01-17 : 11:52:32
Hi all!

I have a form search result(by ASP) all custumer buy product in a day. Result include ID,Name,ProductId,Price,Time. Now, i want my page print total "Price" of all customer buy product in time. Please help me

georgev
Posting Yak Master

122 Posts

Posted - 2008-02-17 : 11:19:10
Simplest answer is to open a second recorset with a query that returns just that!
[CODE]
SELET Sum(price)
FROM yourTable
WHERE DateAdd(dd, DateDiff(dd, 0, date_purchased), 0) = DateAdd(dd, DateDiff(dd, 0, GetDate()), 0)
[/CODE]



George
<3Engaged!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-17 : 16:27:08
Simpler...

SELET Sum(price)
FROM yourTable
WHERE DateDiff(dd, 0, date_purchased) = DateDiff(dd, 0, GetDate())

But if you are interested in using your existing indexes, use

declare @anyday datetime

set @anyday = '20080213'

SELECT Sum(price)
FROM yourTable
WHERE date_purchased >= dateadd(day, DateDiff(day, '19000101', @anyday), '19000101')
and date_purchased < dateadd(day, DateDiff(day, '18991231', @anyday), '19000101')



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -