I need a sample query for the following if possible.
I can't seem to get anything to work (I tried if exists, not in, etc..). All I have right now is a basic select statement, I'm just stuck, and my SQL is terrible:
Select
UserID,
Date,
Type,
Step
from TableA
If a userID has rows with "Value A" AND rows with "Value B" (at least one row of Value A) in the "Step" column, then only show rows that have "Value B" (exclude all rows that contain "Value A") by userID.
For example:
Original Table Source:
UserID | Date | Type | Step
-------+-----------+------+---------
24261 | 12/4/2021 | Doc | Value B
24261 | 12/4/2021 | Sig | Value A
24315 | 12/4/2021 | Sig | Value A
24331 | 12/4/2021 | Doc | Value B
24331 | 12/4/2021 | Sig | Value A
24328 | 12/4/2021 | Text | Value C
24341 | 12/4/2021 | Doc | Value B
24341 | 12/4/2021 | Sig | Value A
24341 | 12/4/2021 | Doc | Value B
24341 | 12/4/2021 | Sig | Value A
24357 | 12/4/2021 | Text | Value C
24357 | 12/4/2021 | Sig | Value A
24357 | 12/4/2021 | text | Value C
Expected Output:
UserID | Date | Type | Step
-------+-----------+------+---------
24261 | 12/4/2021 | Doc | Value B
24315 | 12/4/2021 | Sig | Value A
24331 | 12/4/2021 | Doc | Value B
24328 | 12/4/2021 | Text | Value C
24341 | 12/4/2021 | Doc | Value B
24341 | 12/4/2021 | Doc | Value B
24357 | 12/4/2021 | Text | Value C
24357 | 12/4/2021 | Sig | Value A
24357 | 12/4/2021 | Text | Value C
Any help would be appreciated.