August 29, 2002 at 9:40 am
i am trying to count the date difference between 2 feilds for multiple entries and them together on the same table I used the call below
Select persid, count(datediff(day,startdate,completiondate,)) as dates
All this does is count the number of date diff there are not the actual amount of days accumilated in each row added together.
Any help please is grateful and thanks you
August 29, 2002 at 10:04 am
I think you need to use sum not count
eg Select persid, sum(datediff(day,startdate,completiondate)) as dates from <table_name>
You might also need to group by persid
September 2, 2002 at 9:56 am
Heres a simple query using northwind showing the form you need
SELECT productid, sum(quantity * unitprice) from [order details] GROUP BY productid
Here I've used the calculation of the columns quantity by price where you would use your datediff calc. I need to group by the productid but not by the columns inside the sum parenthesises
I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961
I have found it is possible to please all of the people all of the time if you do exactly what they want. Harold Macmillan 1961
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply