Please help me with SQL coding problems. Although the departments table has 27 r
ID: 3585243 • Letter: P
Question
Please help me with SQL coding problems.
Although the departments table has 27 records, not every defined department has employees in it. Write down the SQL to show the unique department_id for all the departments which has employees in it.
2.Write down the SQL to show all the employee information for those whose department_id is 60.
4. Write down the SQL to show the first name and last name for those employees satisfying one of the following conditions (1) hire_date is after 01/01/2008 and before 12/31/2008, (2)salary is above 8000
5.Write down the SQL to show the average salary of employees whose hire_date is after 01/01/2008 and before 12/31/2008. (Hint: 1 record)
6.Write down the SQL to show the full name (in one attribute) and hire_date of employees, and sortrecords according to hire_date in a descending orde
Explanation / Answer
Answer:
Select * from employees where department_id=60;
2)
select first_name, last_name from employees where (hire_date > to_date('01-01-2008', 'MM-DD-YYYY')
and hire_date < to_date('12-
31-2008', 'MM-DD-YYYY')) or salary>8000;
3)
select avg(salary) from employees where hire_date > to_date('01-
01-2008', 'MM-DD-YYYY') and
hire_date < to_date('12-31-2008', 'MM-
DD-YYYY');
4)
select first_name || ' ' || last_name as FullName, hire_date from employees order by hire_date desc;