Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What's the difference between these two queries?

This query gives me 10,185

select SUM(int_BenefitEquation) AS total_hours from net_BudgetTools..tbl_DEVELOPERS_Projects where dte_DateOnProduction<='2015-04-07'

This query gives me 9,075

SELECT      SUM(ISNULL(int_BenefitEquation, 0)) AS BenefitHours FROM net_BudgetTools..tbl_DEVELOPERS_Projects
WHERE      
DATEPART(year, dte_DateOnProduction) = '2015'

What's the difference? Basically, I want all of the projects that went into production this year. What's the difference between these two queries that I would wind up with two different figures?
SOLUTION
Avatar of Ramachandar N
Ramachandar N

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of SStory
SStory
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Check if the difference are from records with date higher than today:
select SUM(int_BenefitEquation) AS total_hours from net_BudgetTools..tbl_DEVELOPERS_Projects where dte_DateOnProduction>GETDATE()

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
<Not an answer, but...>

brucegust - SQL expert PorletPaul's article titled Beware of Between would be an excellent read for your situation.