Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create HR database with the following tables. Write SQL query for the following questions based on above database. No. Question 1. Write a SQL query

Create HR database with the following tables. Write SQL query for the following questions based on above database. No. Question 1. Write a SQL query to find those employees whose salaries are less than 6000. Return full name (first and last name), and salary. 2. Write a SQL query to find those employees whose last name is "McEwen". Return first name, last name and department ID. 3. Write a SQL query to identify employees who do not have a department number. 4. Write a SQL query to find the details of 'Marketing' department. 5. write a SQL query to find those employees whose first name does not contain the letter M. Sort the result-set in ascending order by department ID. 6. write a SQL query to find those employees who earn between 8000 and 12000 (Begin and end values are included.) and get some commission. These employees joined before 1987-06-05 and were not included in the department numbers 40, 120 and 70. 7. write a SQL query to find those employees who do not earn any commission. Return full name (first and last name), and salary. 8. write a SQL query to find the employees whose first name ends with the letter m. Return the first and last name, and salary. 9. write a SQL query to find those employees who were hired between November 5th, 2007 and July 5th, 2009. Return full name (first and last), job id and hire date. 10. write a SQL query to find those employees who work either in department 70 or 90. Return full name (first and last name), department id. 11. write a SQL query to find those employees who work under a manager. Return full name (first and last name), salary, and manager ID 12. write a SQL query to find employees whose first names contain the letters D, S, or N. Sort the result-set in descending order by salary. Return all fields. 13. write a SQL query to find those employees whose first name contains a character 's' in the third position. Return first name, last name and department id 14. write a SQL query to find those employees who worked more than two jobs in the past. Return employee id. 15. write a SQL query to count the number of employees, the sum of all salary, and difference between the highest salary and lowest salaries by each job id. Return job_id, count, sum, salary_difference. 16. write a SQL query to find each job ids where two or more employees worked for more than 300 days. Return job id 17. write a SQL query to count the number of cities in each country. Return country ID and number of cities. 18. write a SQL query to count the number of employees worked under each manager. Return manager ID and number of employees. 19. write a SQL query to find all jobs. Sort the result-set in descending order by job title. 20. write a SQL query to calculate the average salary of employees who receive a commission percentage for each department. Return department id, average salary. 21. write a SQL query to find the departments where any manager manages four or more employees. Return department_id. 22. write a SQL query to compute the average salary of each job ID. Exclude those records where average salary is higher than 8000. Return job ID, average salary. 23. write a SQL query to find those job titles where maximum salary falls between 12000 and 18000 (Begin and end values are included.). 24. write a SQL query to find details of those jobs where the minimum salary exceeds 9000. Return all the fields of jobs. 25. write a SQL query to find the first name, last name, department number, and department name for each employee. 26. write a SQL query to find the first name, last name, department, city, and state province for each employee. 27. write a SQL query to find all those employees who work in department ID 80 or 40. Return first name, last name, department number and department name. 28. write a SQL query to find all departments, including those without employees. Return first name, last name, department ID, department name. 29. write a SQL query to find the employees who earn less than the employee of ID 182. Return first name, last name and salary. 30. write a SQL query to find the employees and their managers. Return the first name of the employee and manager. 31. write a SQL query to find out which employees have or do not have a department. Return first name, last name, department ID, department name 32. write a SQL query to find the employees who work in the same department as the employee with the last name Taylor. Return first name, last name and department ID. 33. write a SQL query to find all employees who joined on or after 1st January 1993 and on or before 31 August 1997. Return job title, department name, employee name, and joining date of the job. 34. write a SQL query to calculate the difference between the maximum salary of the job and the employee's salary. Return job title, employee name, and salary difference. 35. write a SQL query to calculate the average salary, the number of employees receiving commissions in that department. Return department name, average salary and number of employees. 36. write a SQL query to find the name of the country, city, and departments, which are running there. 37. write a SQL query to calculate the average salary of employees for each job title. 38. write a SQL query to find the employees who earn $12000 or more. Return employee ID, starting date, end date, job ID and department ID. 39. write a SQL query to find out which departments have at least two employees. Group the result set on country name and city. Return country name, city, and number. 40. write a SQL query to calculate the number of days worked by employees in a department of ID 80. Return employee ID, job title, number of days worked. 41. write a SQL query to find full name (first and last name), and salary of all employees working in any department in the city of London. 42. write a SQL query to find the department name, department ID, and number of employees in each department. 43. write a SQL query to find out the full name (first and last name) of the employee with an ID and the name of the country where he/she is currently employed. 44. write a SQL query to find those employees who joined after 7th September 1987. Return all the fields. 45. write a SQL query to find the employees whose first or last name begins with 'D'. Return first name, last name.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

More Books

Students also viewed these Databases questions