Soru
tables to answer the following questions by SQL commands. employee (ssn fname address, city, dob alary, job code) (job code, job position) a) Concatenate and display the first name and last name of all employees. List them in a descending order according to their salary. (4 points) SELECT CONCAT ","WS(","fname ", "Iname') AS FullName FROM employee ORDER BY FullName DESC; b) List all employees first name and last name who was born between 2000 and 2005 (4 points) SELECT fname , Iname FROM employee WHERE BORN BETWEEN 2000 AND 2005; c) List the SSN and salary of all employees who cam more than 5000 Change the column name of salary to MANAGERS.(4 points) SELECT SSN , salary AS MANAGERS FROM employee WHERE MANAGERS >5000; d) Find the total amount of salary each employee will earn at the end of 1 year (4 points) c) List the number of employees in each job. Display those which has less than 3 in the group.(7 points)
Çözüm
4
(280 Oylar)
Yasemin
Profesyonel · 6 yıl öğretmeni
Uzman doğrulaması
Cevap
a) Concatenate and display the first name and last name of all employees. List them in a descending order according to their salary.```sqlSELECT CONCAT(fname, ', Iname) AS FullNameFROM employeeORDER BY alary DESC;```b) List all employees first name and last name who was born between 2000 and 2005.```sqlSELECT fname, InameFROM employeeWHERE dob BETWEEN '2000-01-01' AND '2005-12-31';```c) List the SSN and salary of all employees who earn more than $5000. Change the column name of salary to MANAGERS.```sqlSELECT SSN, alary AS MANAGERSFROM employeeWHERE alary > 5000;```d) Find the total amount of salary each employee will earn at the end of 1 year.```sqlSELECT SSN, alary * 12 AS TotalSalaryFROM employee;```e) List the number of employees in each job. Display those which has less than 3 in the group.```sqlSELECT job_code, COUNT(*) AS EmployeeCountFROM employeeGROUP BY job_codeHAVING EmployeeCount < 3;```