Hi experts,
I need a solution to retrieve records using SUM and GroupBy.
My problem:
I have two tables, refer to attachment of database and/or picture. SQL Code below also. I first need to aggregate the EstimateAmount in tblTaskCheckEstimate and GroupBY TaskID. Then there is two where clause in the query.
I'm hoping this makes sense to someone. Let me know if more clarification of the problem is needed.
Thanks
I need a solution to retrieve records using SUM and GroupBy.
My problem:
I have two tables, refer to attachment of database and/or picture. SQL Code below also. I first need to aggregate the EstimateAmount in tblTaskCheckEstimate and GroupBY TaskID. Then there is two where clause in the query.
- First the aggregated estimate amount need to be more than 200
- The aggregated amount need to include and record where Final Estimate Amount = False
Code:
SELECT tblTask.TaskID, Sum(tblTaskCheckEstimate.EstimateAmount) AS SumOfEstimateAmount, tblTaskCheckEstimate.FinalEstimateApprove
FROM tblTask INNER JOIN tblTaskCheckEstimate ON tblTask.TaskID = tblTaskCheckEstimate.TaskID
GROUP BY tblTask.TaskID, [B]tblTaskCheckEstimate.FinalEstimateApprove[/B]
HAVING (((Sum(tblTaskCheckEstimate.EstimateAmount))>200) AND ((tblTaskCheckEstimate.FinalEstimateApprove)=False));
I'm hoping this makes sense to someone. Let me know if more clarification of the problem is needed.
Thanks