I am looking for a solution where I want to select only one row from a DB Table depending on a column which like a flag.
A sample DB table looks like this:
C1 | C2 | C3
-----------------
A1 | N1 |
A1 | N2 | X
A1 | N3 |
A2 | N21 | X
A2 | N22 |
where C1 and C2 are key fields. In this example, A1 has 3 entries and one of which has a flag true ('X').
I want to select either the entry with the flag = 'X' or the minimum of C2 value.
Is this possible in ABAP Open SQL? I tried using case statement but does not give me the required result.
EDIT 1:
In the above example: result will be
A1 | N2
A2 | N21
and when the flag is false or empty then:
A1 | N1
A2 | N21