I have a table with 2 columns ,So for each of the loans Either Letter A, Letter B or both of them is being sent to the Loan applicant.
Base Table I need to create a new column that sets a Flag =1 ( If Letter A is sent ) , 2 ( If letter B is sent) and 3 ( If both the Letter A and Letter B is sent) as below
I have tried a method to generate a row number for each loan for the specific letter as below. I need to then find those rows where the no of times the ROW_NUM =1 is GREATER THAN 1 and assign a flag
SELECT *,
ROW_NUMBER() OVER(PARTITION BY LOAN_NO, Letter ORDER BY LOAN_NO) AS ROW_NUM
FROM TableA
Can someone help me to proceed in this method or any alternative method to set the flags.
{}.