I am doing my homework in Oracle.
I have to create a complex view and after creating the view, I have to modify it.
The question says that the creation of the view must be able to handle the situation when there is no department_name in existence. I am not sure if I have to use this NVL(d.department_name, 'No department established yet')
The second question is I have to modify the view to change the column names to aliases such as department_name to “Departments” and include other countries in the view that is not included in the view. The below is the view that I have created and I need help please.
CREATE VIEW jack_vu AS
SELECT NVL(d.department_name, 'No department established yet') "department_name"
, l.city
, l.state_province
FROM locations l
JOIN departments d
ON (l.location_id = d.location_id)
WHERE UPPER(l.country_id) LIKE 'CA'
OR UPPER(l.country_id) LIKE 'IT';
Looks like you are on the right track here.
The NVL function is used to handle null values, so that seems to be ok. You are already using an alias “department_name”. You can also use aliases for normal columns i.e.: select column_name as “alias” from table;
You can also use “create or replace view …” to change an already existing view.