Interview Question

What is COALESCE?

COALESCE returns the first available non-null value.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

COALESCE returns the first non-null argument. • Arguments are considered from left to right. • All arguments must be convertible to a compatible result type. • It is useful for defaults, but it does not change stored data.

💡 SQL Example

SELECT COALESCE(nickname, full_name, 'Unknown') AS display_name FROM customers;

Result

Maya Rao

⚡ Quick Revision

COALESCE returns the first available non-null value.