I am new with SQL and have some data in table and want to make grouping based on column CLASS and STATUS with condition based on the value in both column. It will group based on the highest order
The Table shown below
Scenario 1
Table Source :
| ID | Class | Status |
|---|---|---|
| 001 | Platinum | ACTIVE |
| 001 | Gold | ACTIVE |
| 001 | Silver | ACTIVE |
| 001 | Regular | ACTIVE |
Output after Grouping:
| ID | Class | Status |
|---|---|---|
| 001 | Platinum | ACTIVE |
Scenario 2
Table Source :
| ID | Class | Status |
|---|---|---|
| 001 | Gold | ACTIVE |
| 001 | Silver | INACTIVE |
| 001 | Regular | INACTIVE |
Output after Grouping:
| ID | Class | Status |
|---|---|---|
| 001 | Gold | ACTIVE |
So basically the grouping will be determined by the value of CLASS and Status
For CLASS the order of grouping is
Platinum > Gold > Silver > Regular
For Status the order of grouping is
ACTIVE > INACTIVE
Is there any way to do this?
Thanks