I am using the following query in my database:
Select ID, coalesce(FName,MName, LName, 'Missing Name') as 'NameToCall', [Phone Number] from Emp
The results show:
I want the ID 6 to not display when the query executes. How do I do it?
I've so far tried taking the column named
FName
outside of the colaesce but, it only displays the whole FName column
CodePudding user response:
select id, phone from emp where coalesce(FName,MName, LName) is not null
CodePudding user response:
SELECT
CASE
WHEN FName IS NULL AND MName IS NULL AND LName IS NULL THEN NULL
ELSE ID
END AS ID
...