I have a table in Oracle SQL as follows.
Account_Id Account_No BS STATUS
1 10 V ACTV
2 11 S DIS
3 12 E NOTACTV
4 10 S DIS
5 12 E ACTV
6 12 V ACTV
I need to get the Account Number (one record) with below Mentioned priority.
1) BS = V && STATUS = ACTV
2) BS = S && STATUS = ACTV
3) BS = E && STATUS = ACTV
4) BS = V && STATUS = NOTACTV
5) BS = S && STATUS = NOTACTV
6) BS = E && STATUS = NOTACTV
7) BS = V && STATUS = DIS
8) BS = S && STATUS = DIS
9) BS = E && STATUS = DIS
I tried using three sql queries with V and checking status ACTV and NOTACTV. I wanted to fetch the data in one sql query so as to optimize this.
How to do this??