My requirement is to display a Column in select query when a condition satisfies and not to display the column when condition is not matched.
For eg : In this simple table below
Name ID Fairness ------ -- -------- harish 3 White ravi 5 brown arun 2 black rahul 5 white
select name, case id when 5 then " I Like to learn more languages" end as Remarks, Fairness from xyz where id=2
My requirement is in the above query "Remarks" column should not be displayed in output, but my output is
Name Remarks Fairness ---- ------- -------- arun null black
Name Fairness ---- -------- arun black
i.e, I need remarks column to be displayed only if the id is 5 in where clause.
Please provide me help to ignore "Remarks" when the condition is not satisfied or met.
Perhaps you want the SQL COALESCE function?
will give blanks instead of nulls.