-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBlank_Status_Codes.sql
More file actions
44 lines (40 loc) · 1.91 KB
/
Blank_Status_Codes.sql
File metadata and controls
44 lines (40 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Blank Status Codes*/
SELECT dbo.loanacct.shortname,
dbo.loanacct.loan_number,
dbo.loan_status_codes.status_code,
CASE dbo.loanacct.status_code_no
When '0' Then 'Active'
When '1' then 'Closed'
When '2' then 'Restructured'
End AS 'Loan Status',
dbo.loanacct_detail.userdef01 AS 'OrderID',
CASE loanacct_detail.userdef10
WHEN '0' THEN 'No'
WHEN '1' THEN 'Yes'
END AS 'Sumbitted to CRM',
dbo.loanacct.current_principal_balance,
dbo.loanacct_ach.Token,
dbo.loanacct_ach.LastFourDigits AS 'CCLastFourDigits',
dbo.loanacct.current_payoff_balance,
dbo.loanacct.input_date,
CASE loanacct_ach.amount_type
WHEN '0' THEN 'Fixed Amount'
WHEN '1' THEN ' Percentage of Principle'
WHEN '2' THEN 'Amount of Billing'
END AS 'Amount Type',
CASE loanacct_ach.billing_type
WHEN '0' THEN 'Billing'
WHEN '1' THEN 'One-Time'
WHEN '2' THEN 'Recurring'
END AS 'Frequency Type',
CASE dbo.loanacct_ach.status
WHEN '0' THEN 'Active'
WHEN '1' THEN 'Disabled'
WHEN '2' THEN 'Expired'
END AS 'ACH Status'
FROM dbo.loanacct WITH (NOLOCK) LEFT OUTER JOIN
dbo.loanacct_statuses ON dbo.loanacct.acctrefno = dbo.loanacct_statuses.acctrefno LEFT OUTER JOIN
dbo.loan_status_codes WITH (NOLOCK) ON dbo.loanacct_statuses.status_code_no = dbo.loan_status_codes.status_code_no LEFT OUTER JOIN
dbo.loanacct_detail WITH (NOLOCK) ON dbo.loanacct.acctrefno = dbo.loanacct_detail.acctrefno LEFT OUTER JOIN
dbo.loanacct_ach WITH (NOLOCK) ON dbo.loanacct.acctrefno = dbo.loanacct_ach.acctrefno
Where dbo.loan_status_codes.status_code is Null and dbo.loanacct.status_code_no = '0'