mardi 12 mai 2020

Writing a query for alternative column names as mentioned below eg

The query for, If the address is missing, displays the email id. If both address and email are missing then display ‘NA’. Give an alias name as CONTACT_DETAILS. Considering the above-mentioned example, please help with writing the query.

SELECT CASE WHEN 1 THEN ifnull(address,email_id)
WHEN 2 THEN ifnull(email_id,'NA') END as contact_details FROM customers;

The query which i tried

Aucun commentaire:

Enregistrer un commentaire