I have code that gives me that gives me the customer name,the purchase date, the date the customer paid out the contract completly but never defaulted before paying out.
I am trying to find out the average numers of days between the 1st and 2nd contract purchase, 2nd and 3rd purchase contract etc. thanks for your help.. I will be grouping this by customer. This code should work but gives an aggregate error message. Would diffdate work here?
SELECT dbo_MRC_Merchants.BusinessName AS Merchant,
dbo_CNT_Contracts.FirstFundingDate AS Purchase,
dbo_CNT_Contracts.BalanceZeroDate AS Closed,
dbo_CNT_v_DefaultedDateHistory.DefaultedDate AS Defaulteddate,
avg(dbo_CNT_Contracts.BalanceZeroDate - dbo_CNT_Contracts.FirstFundingDate)
FROM (dbo_MRC_Merchants INNER JOIN dbo_CNT_Contracts ON dbo_MRC_Merchants.MerchantID = dbo_CNT_Contracts.MerchantID)
LEFT JOIN dbo_CNT_v_DefaultedDateHistory ON dbo_CNT_Contracts.ContractID = dbo_CNT_v_DefaultedDateHistory.contractid
WHERE (((dbo_CNT_Contracts.BalanceZeroDate) Is Not Null) AND ((dbo_CNT_v_DefaultedDateHistory.DefaultedDate) Is Null))
Group BY dbo_MRC_Merchants.BusinessName;
I am trying to find out the average numers of days between the 1st and 2nd contract purchase, 2nd and 3rd purchase contract etc. thanks for your help.. I will be grouping this by customer. This code should work but gives an aggregate error message. Would diffdate work here?
SELECT dbo_MRC_Merchants.BusinessName AS Merchant,
dbo_CNT_Contracts.FirstFundingDate AS Purchase,
dbo_CNT_Contracts.BalanceZeroDate AS Closed,
dbo_CNT_v_DefaultedDateHistory.DefaultedDate AS Defaulteddate,
avg(dbo_CNT_Contracts.BalanceZeroDate - dbo_CNT_Contracts.FirstFundingDate)
FROM (dbo_MRC_Merchants INNER JOIN dbo_CNT_Contracts ON dbo_MRC_Merchants.MerchantID = dbo_CNT_Contracts.MerchantID)
LEFT JOIN dbo_CNT_v_DefaultedDateHistory ON dbo_CNT_Contracts.ContractID = dbo_CNT_v_DefaultedDateHistory.contractid
WHERE (((dbo_CNT_Contracts.BalanceZeroDate) Is Not Null) AND ((dbo_CNT_v_DefaultedDateHistory.DefaultedDate) Is Null))
Group BY dbo_MRC_Merchants.BusinessName;