Home > Enterprise >  Using Coalesce, How do I not display null values?
Using Coalesce, How do I not display null values?

Time:03-30

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: Query results

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
...
  • Related