G
Guest
I have a looming report deadline, and suddenly a query I thought I had fixed
shows me it's not fixed. In the SQL below, please please PLEASE look at the
subquery and tell me how I can fix this. When I try to run the query, I get
the error message that I cannot I have an aggregate function in the Where
clause of the subquery.
Please understand that while all the other fields are being summed, what I'm
really trying to do with the field in the subquery is select the Loan
Portfolio Outstanding (LPO) amount for the *most recent month*. In other
words, if I run the query in December, I want it to give me the LPO amount
for November. I *do not* want it to sum the LPO amounts for October and
November.
Thanks!
GwenH
SELECT Retail_Manager_Activities.Retail_Manager, Sum(SELECT
[Retail_Manager_Activities].[Loan_Portfolio_Outstanding] FROM
[Retail_Manager_Activities] WHERE [Retail_Manager_Activities].[Month] =
Max([Retail_Manager_Activities].[Month]))
AS LPO_Qtr4, Sum(Retail_Manager_Activities.New_Loans_Funded) AS NLF_Qtr4,
Sum(Retail_Manager_Activities.New_Deposits) AS ND_Qtr4,
Sum(Retail_Manager_Activities.Security_Referrals) AS SR_Qtr4,
Sum(Retail_Manager_Activities.Trust_Referrals) AS TR_Qtr4,
Sum(Retail_Manager_Activities.Mortgage_Closed) AS MC_Qtr4
FROM Retail_Manager_Activities
WHERE (((Retail_Manager_Activities.Month)Between #10/1/2005# And
#12/31/2005#))
GROUP BY Retail_Manager_Activities.Retail_Manager;
shows me it's not fixed. In the SQL below, please please PLEASE look at the
subquery and tell me how I can fix this. When I try to run the query, I get
the error message that I cannot I have an aggregate function in the Where
clause of the subquery.
Please understand that while all the other fields are being summed, what I'm
really trying to do with the field in the subquery is select the Loan
Portfolio Outstanding (LPO) amount for the *most recent month*. In other
words, if I run the query in December, I want it to give me the LPO amount
for November. I *do not* want it to sum the LPO amounts for October and
November.
Thanks!
GwenH
SELECT Retail_Manager_Activities.Retail_Manager, Sum(SELECT
[Retail_Manager_Activities].[Loan_Portfolio_Outstanding] FROM
[Retail_Manager_Activities] WHERE [Retail_Manager_Activities].[Month] =
Max([Retail_Manager_Activities].[Month]))
AS LPO_Qtr4, Sum(Retail_Manager_Activities.New_Loans_Funded) AS NLF_Qtr4,
Sum(Retail_Manager_Activities.New_Deposits) AS ND_Qtr4,
Sum(Retail_Manager_Activities.Security_Referrals) AS SR_Qtr4,
Sum(Retail_Manager_Activities.Trust_Referrals) AS TR_Qtr4,
Sum(Retail_Manager_Activities.Mortgage_Closed) AS MC_Qtr4
FROM Retail_Manager_Activities
WHERE (((Retail_Manager_Activities.Month)Between #10/1/2005# And
#12/31/2005#))
GROUP BY Retail_Manager_Activities.Retail_Manager;