sql server programming:
Hi All,
I have a this query which works fine,
SELECT Hours *
(SELECT Rate FROM tbRate WHERE ID = (SELECT MAX(ID) FROM
tbRate WHERE Project=T.Project AND Employee=T.Employee))
as Amt
FROM EmployeeTime T
The output is like this:
Amt
-------------
200.0
300.0
If I want to sum the two amount, the query fails.
Query I wrote is :
SELECT SUM(Hours *
(SELECT Rate FROM tbRate WHERE ID = (SELECT MAX(ID) FROM
tbRate WHERE Project=T.Project AND Employee=T.Employee)))
as TotalAmt
FROM EmployeeTime T
This fails by saying:
"Cannot perform an aggregate function on an expression
containing an aggregate or a subquery."
Can anyone help me in accomplish this task.
Thanks in advance
qAnand