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.0280 Voting
Yasemin
Profesyonel · 6 yıl öğretmeniUzman 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.<br /><br />```sql<br />SELECT CONCAT(fname, ', Iname) AS FullName<br />FROM employee<br />ORDER BY alary DESC;<br />```<br /><br />b) List all employees first name and last name who was born between 2000 and 2005.<br /><br />```sql<br />SELECT fname, Iname<br />FROM employee<br />WHERE dob BETWEEN '2000-01-01' AND '2005-12-31';<br />```<br /><br />c) List the SSN and salary of all employees who earn more than $5000. Change the column name of salary to MANAGERS.<br /><br />```sql<br />SELECT SSN, alary AS MANAGERS<br />FROM employee<br />WHERE alary > 5000;<br />```<br /><br />d) Find the total amount of salary each employee will earn at the end of 1 year.<br /><br />```sql<br />SELECT SSN, alary * 12 AS TotalSalary<br />FROM employee;<br />```<br /><br />e) List the number of employees in each job. Display those which has less than 3 in the group.<br /><br />```sql<br />SELECT job_code, COUNT(*) AS EmployeeCount<br />FROM employee<br />GROUP BY job_code<br />HAVING EmployeeCount < 3;<br />```
Derecelendirmek için tıklayın: