As far as the cust_nbr is concerned, here is the statement.
SELECT CASE PATINDEX('%-%',Loan_nbr)
WHEN 0 THEN ''
ELSE SUBSTRING(Loan_nbr,
PATINDEX('%-%',Loan_nbr)+1,
LEN(Loan_nbr))
+
CASE WHEN Cust_nbr IS NULL THEN ''
ELSE Cust_nbr...
As I understand from your message, I think you need the number before "-" for the loan number. Here is how you pull it out. In this example, c1 is the loan_nbr column and table1 is the table name.
SELECT CASE PATINDEX('%-%',c1)
WHEN 0 THEN c1
ELSE...
I don't think this is possible. When you say '*' in the select statement, that will fetch all the records in the table. So, the 'distinct' reserved word has no significance.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.