G
Gwen H
I have a query that essentally pulls loan and deposit activity for the most
recent quarter from a table. The query totals some of the activity for the
entire quarter, and is *supposed* to pull the most recent month's numbers for
Deposits Outstanding and Loan Portfolio Outstanding. The query uses Last to
do this. The problem is this: Since there is nothing in the query to tell it
to order the data by month *before* it selects the last month's numbers for
deposits and loans, it doesn't always do this consistently. How can I modify
this query to make sure it always pulls June's loan and deposit portfolio,
assuming I'm running the query in July? I've pasted the SQL below.
Many thanks in advance!
SELECT Assistant_Retail_Manager_Activities.Assistant_Retail_Manager,
Last(Assistant_Retail_Manager_Activities.Deposits_Outstanding) AS DO_Qtr2,
Sum(Assistant_Retail_Manager_Activities.New_Deposits) AS ND_Qtr2,
Last(Assistant_Retail_Manager_Activities.Loan_Portfoliutstanding) AS
LPO_Qtr2, Sum(Assistant_Retail_Manager_Activities.New_Loans_Funded) AS
NLF_Qtr2, Sum(Assistant_Retail_Manager_Activities.Security_Referrals) AS
SR_Qtr2, Sum(Assistant_Retail_Manager_Activities.Trust_Referrals) AS TR_Qtr2,
Sum(Assistant_Retail_Manager_Activities.Mortgage_Closed) AS MC_Qtr2,
Avg(Assistant_Retail_Manager_Activities.Cross_Sell_Ratio) AS XSR_Qtr2
FROM Assistant_Retail_Manager_Activities
WHERE (((Assistant_Retail_Manager_Activities.Month)>=#4/1/2005# And
(Assistant_Retail_Manager_Activities.Month)<=#6/30/2005#))
GROUP BY Assistant_Retail_Manager_Activities.Assistant_Retail_Manager;
recent quarter from a table. The query totals some of the activity for the
entire quarter, and is *supposed* to pull the most recent month's numbers for
Deposits Outstanding and Loan Portfolio Outstanding. The query uses Last to
do this. The problem is this: Since there is nothing in the query to tell it
to order the data by month *before* it selects the last month's numbers for
deposits and loans, it doesn't always do this consistently. How can I modify
this query to make sure it always pulls June's loan and deposit portfolio,
assuming I'm running the query in July? I've pasted the SQL below.
Many thanks in advance!
SELECT Assistant_Retail_Manager_Activities.Assistant_Retail_Manager,
Last(Assistant_Retail_Manager_Activities.Deposits_Outstanding) AS DO_Qtr2,
Sum(Assistant_Retail_Manager_Activities.New_Deposits) AS ND_Qtr2,
Last(Assistant_Retail_Manager_Activities.Loan_Portfoliutstanding) AS
LPO_Qtr2, Sum(Assistant_Retail_Manager_Activities.New_Loans_Funded) AS
NLF_Qtr2, Sum(Assistant_Retail_Manager_Activities.Security_Referrals) AS
SR_Qtr2, Sum(Assistant_Retail_Manager_Activities.Trust_Referrals) AS TR_Qtr2,
Sum(Assistant_Retail_Manager_Activities.Mortgage_Closed) AS MC_Qtr2,
Avg(Assistant_Retail_Manager_Activities.Cross_Sell_Ratio) AS XSR_Qtr2
FROM Assistant_Retail_Manager_Activities
WHERE (((Assistant_Retail_Manager_Activities.Month)>=#4/1/2005# And
(Assistant_Retail_Manager_Activities.Month)<=#6/30/2005#))
GROUP BY Assistant_Retail_Manager_Activities.Assistant_Retail_Manager;