Reputation: 3
Name SCRE_TXT SRCE_NBR
MAX PHONE 10
MAX EMAIL 20
MAX ADDRESS 90
MAX PHONE 88
MAX PHONE 30
MAX EMAIL 21
MAX PHONE 30
How would I check if the SRCE_NBR is distinct for only the rows with phone in it. Otherwise don't check SRCE_NBR at ALL.
Desired output would be
Name SCRE_TXT SRCE_NBR
MAX PHONE 10
MAX EMAIL 20
MAX ADDRESS 90
MAX PHONE 88
MAX PHONE 30
Upvotes: 0
Views: 57
Reputation:
Can you first select all the Phone rows, using distinct and then union that result with all the rows that are not Phone rows?
Select distinct * from ... where SCRE_TXT = 'PHONE'
UNION ALL
Select * from ... where SCRE_TXT <> 'PHONE'
Upvotes: 1