Docsity

SQL Statements for Employee Table, Exercises of Computer Science

Toggle sidebar
bg1
STRUCTURED QUERY LANGUAGE (SQL)
I.
1. From the Table1. Employee, provide and write the corresponding SQL statements asked in the
following.
a. Salary = 20000
SELECT Employee_Name, DEPT FROM Employee WHERE SALARY = 20000;
b. Employee under Sales department
SELECT Employee_Name FROM Employee WHERE DEPT = ‘Sales’;
c. Employee ID > 1003 or Employee ID < 1002
SELECT Employee_ID, Employee_Name, Salary FROM Employee WHERE Employee_ID >
1003 OR Employee_ID < 1002;
d. Employees with a salary 20000, 15000, 25000 use the IN operator
SELECT Employee_ID, Employee_Name, Salary FROM Employee WHERE IN (20000, 15000,
25000);
pf2

Partial preview of the text

Download SQL Statements for Employee Table and more Exercises Computer Science in PDF only on Docsity!

STRUCTURED QUERY LANGUAGE (SQL)

I.

  1. From the Table1. Employee, provide and write the corresponding SQL statements asked in the following. a. Salary = 20000 SELECT Employee_Name, DEPT FROM Employee WHERE SALARY = 20000; b. Employee under Sales department SELECT Employee_Name FROM Employee WHERE DEPT = ‘Sales’; c. Employee ID > 1003 or Employee ID < 1002 SELECT Employee_ID, Employee_Name, Salary FROM Employee WHERE Employee_ID > 1003 OR Employee_ID < 1002; d. Employees with a salary 20000, 15000, 25000 use the IN operator SELECT Employee_ID, Employee_Name, Salary FROM Employee WHERE IN (20000, 15000, 25000);

II.

  1. Use the table below and write SQL statements asked in the following: a. Distinct Department SELECT DISTINCT DEPT FROM Employee; b. Average of the salary SELECT AVG(Salary) FROM Employee; c. Sum of the salary SELECT SUM(Salary) FROM Employee; d. Minimum salary SELECT MIN(Salary) FROM Employee; e. Maximum salary SELECT MAX(Salary) FROM Employee; f. Number of employees SELECT COUNT(Employee_Name) FROM Employee;