q1:
SELECT SUBSTR(o.first_name,1,1)||' '||o.last_name "NAME", FROM employees o WHERE o.salary > (SELECT AVG(i.salary) FROM employees i WHERE i.department_id = o.department_id) I have a department table with department_id and department_name || how to join it to this result to display the results of the subquery and dep name ?
q2)this throws an error , after adding the last line : why?
SELECT SUBSTR(first_name, 1, 1) || ' ' || last_name "Employee Name", department_id "Department Id", to_char(NULL) "Department Name", to_char(NULL) " City" FROM employees UNION SELECT to_char(NULL) "Employee Name" , department_id "Department ID", department_name "Department Name", to_char(NULL)" City" FROM departments UNION SELECT to_char(NULL) "Employee Name" , to_char(NULL) "Department Id", to_char(NULL) "Department Name" ,to_char(NULL )"City" FROM locations