I am returning a query with names, courses and course codes, but where the course code is null i would like to display “NOT ENROLLED”.
Could I do this by using a ‘default’?
The select statement is coming from a VIEW would this make any difference.
CREATE VIEW STUDENT_LIST
(studentname, dateofbirth, coursecode)
AS
SELECT COURSECODE, STUDENTNAME, DATEOFBIRTH
FROM STUDENT;
SELECT STUDENTNAME, DATEOFBIRTH, NVL(COURSECODE,"NOT_ENROLLED")
FROM STUDENT_LIST;
I get the reply NOT ENROLLED invalid identifier… I have tried without quotes
I am using oracle.
ORACLE has
NVL()SQL Server has
ISNULL()MySQL has
IFNULL()All of the above and PostgreSQL support
COALESCE().So,
or
in Oracle.