I have the need to select records from a SQL database but skip all records below records with specific values in the column.
Example data from multiple joined tables:
POSITION CODE VALUE
1 A001 No
2 A002 Yes
2.1 A005 No
2.2 A006 No
3 A003 No
4 A004 No
4.1 A007 No
I would like that positions 2.1 and 2.2 to be excluded from the result because they reside below the record with VALUE=Yes:
POSITION CODE VALUE
1 A001 No
2 A002 Yes
3 A003 No
4 A004 No
4.1 A007 No
WHERE VALUE<>'YES'
Just leaves out the lines which contain this value. I don't know how to exclude the lines below.
The value Yes can exist on any level in the structure. How can I exclude those lines below?