B
Ben
Hi - I have a table "Data" which doesn't have required fields for each
record. What I'm trying to do is use a query to find the last value input in
certain fields. Currently, instead the result is '0' since the last record
doesn't have any data completed. I'm not sure how to do this properly. I've
used the LAST and MAX commands. Below is the SQL Statement. (Sorry for not
explaining better.)
SELECT DISTINCTROW Sum(Data.[# Calls Received]) AS [Sum Of # Calls
Received], Sum(Data.[# Calls Answered]) AS [Sum Of # Calls Answered],
Sum(Data.[# Calls w/in SL]) AS [Sum Of # Calls w/in SL], Sum(Data.[PVS Trades
Online]) AS [SumOfPVS Trades Online], Sum(Data.[PVS Trades Desk]) AS
[SumOfPVS Trades Desk], Sum(Data.[PVK Trades Online]) AS [SumOfPVK Trades
Online], Sum(Data.[PVK Trades Desk]) AS [SumOfPVK Trades Desk],
Max(Data.AUMMM) AS MaxOfAUMMM, Max(Data.AUMEquity) AS MaxOfAUMEquity,
Max(Data.AUMMF) AS MaxOfAUMMF, Max(Data.AUMOptions) AS MaxOfAUMOptions,
Max(Data.AUMBonds) AS MaxOfAUMBonds, Max(Data.AUMOther) AS MaxOfAUMOther,
Last(Data.AUDDate) AS LastOfAUDDate, Sum(Data.PVSTradesEquity) AS
SumOfPVSTradesEquity, Sum(Data.PVSTradesMF) AS SumOfPVSTradesMF,
Sum(Data.PVSTradesOption) AS SumOfPVSTradesOption, Sum(Data.PVSTradesFI) AS
SumOfPVSTradesFI, Sum(Data.PVKTradesEquity) AS SumOfPVKTradesEquity,
Sum(Data.PVKTradesMF) AS SumOfPVKTradesMF, Sum(Data.PVKTradesOption) AS
SumOfPVKTradesOption, Sum(Data.PVKTradesFI) AS SumOfPVKTradesFI,
Sum(Data.[Prime Broker Trades]) AS [SumOfPrime Broker Trades], Sum(Data.[GFV
Accounts]) AS [SumOfGFV Accounts] INTO WTD
FROM Data
WHERE (((Data.[Business Date]) Between [Input Beginning of Week Date] And
[Input End of Week Date (Saturday)]));
record. What I'm trying to do is use a query to find the last value input in
certain fields. Currently, instead the result is '0' since the last record
doesn't have any data completed. I'm not sure how to do this properly. I've
used the LAST and MAX commands. Below is the SQL Statement. (Sorry for not
explaining better.)
SELECT DISTINCTROW Sum(Data.[# Calls Received]) AS [Sum Of # Calls
Received], Sum(Data.[# Calls Answered]) AS [Sum Of # Calls Answered],
Sum(Data.[# Calls w/in SL]) AS [Sum Of # Calls w/in SL], Sum(Data.[PVS Trades
Online]) AS [SumOfPVS Trades Online], Sum(Data.[PVS Trades Desk]) AS
[SumOfPVS Trades Desk], Sum(Data.[PVK Trades Online]) AS [SumOfPVK Trades
Online], Sum(Data.[PVK Trades Desk]) AS [SumOfPVK Trades Desk],
Max(Data.AUMMM) AS MaxOfAUMMM, Max(Data.AUMEquity) AS MaxOfAUMEquity,
Max(Data.AUMMF) AS MaxOfAUMMF, Max(Data.AUMOptions) AS MaxOfAUMOptions,
Max(Data.AUMBonds) AS MaxOfAUMBonds, Max(Data.AUMOther) AS MaxOfAUMOther,
Last(Data.AUDDate) AS LastOfAUDDate, Sum(Data.PVSTradesEquity) AS
SumOfPVSTradesEquity, Sum(Data.PVSTradesMF) AS SumOfPVSTradesMF,
Sum(Data.PVSTradesOption) AS SumOfPVSTradesOption, Sum(Data.PVSTradesFI) AS
SumOfPVSTradesFI, Sum(Data.PVKTradesEquity) AS SumOfPVKTradesEquity,
Sum(Data.PVKTradesMF) AS SumOfPVKTradesMF, Sum(Data.PVKTradesOption) AS
SumOfPVKTradesOption, Sum(Data.PVKTradesFI) AS SumOfPVKTradesFI,
Sum(Data.[Prime Broker Trades]) AS [SumOfPrime Broker Trades], Sum(Data.[GFV
Accounts]) AS [SumOfGFV Accounts] INTO WTD
FROM Data
WHERE (((Data.[Business Date]) Between [Input Beginning of Week Date] And
[Input End of Week Date (Saturday)]));