August 10, 2015 at 7:17 am
I am trying to accomplish something very complicated or can be easy.
I am trying to calculate total hours spent on a project and if the budget cost is more than the actual cost then get the hours that are within the budget cost.
CASE WHEN sum(TotalBudgetCost) - sum(CurrentTotalCostTAmount)) < 0 then Sum(totalhours) * costprice
--where sum(TotalBudgetCost) - sum(CurrentTotalCostTAmount)) > 0 --
and this is where I am having issue with. Please let me know if I am not clear enough.
August 10, 2015 at 7:55 am
without more details, i'm just throwing an example out there;
shouldn't you calculate the cost of all projects, and only filter on the criteria?
maybe something more along the lines of this?
SELECT
SomeProjectID,
SomeProjectName,
Sum(totalhours),
Sum(totalhours) * MIN(costprice)
FROM SomeTable
group by SomeProjectID,SomeProjectName
HAVING (sum(TotalBudgetCost) - sum(CurrentTotalCostTAmount)) < 0
Lowell
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply