User_ID
User_Name
Salary
Department
201
William
10000
MRKT
202
Michael
20000
HR
203
Anthony
30000
MRKT
204
Aiden
40000
HR
205
Matthew
50000
IT
Perform the following queries for above table:
1. Write a SQL query to display User name who is taking maximum salary.
2. Write a SQL query to display second highest salary from user table.
3. Find names of user starting with ‘A’.
4. Find number of users working in department ‘HR’.
5. Print details of users whose name ends with ‘m’ and contains 6 Alphabets.
6. Print details of users whose salary between 20000 and 50000.
7. How many records do we have?
8. write a query to find How many jobs do we have?
10. Add Column Bonus Salary in usertable.
1.
SELECT User_Name, MAX(Salary)
FROM Employees;
2.
SELECT MAX(salary)
FROM Employees
WHERE Salary IN
(SELECT Salary FROM Employees MINUS SELECT MAX(Salary)
FROM Employees);
3.
SELECT *
FROM Employees
WHERE User_Name LIKE 'A%';
4.
SELECT COUNT(User_ID)
FROM Employees
WHERE Department== "HR";
5.
SELECT *
FROM Employees
WHERE User_Name LIKE 'm%' AND LEN (User_Name)==6;
6.
SELECT *
FROM Employees
WHERE Salary BETWEEN 20000 AND 50000;
7.
SELECT COUNT(*) FROM Employees;
8.
SELECT COUNT(DISTINCT Department)
FROM Employees;
9.
SELECT DISTINCT Department
FROM Employees;
10.
ALTER TABLE Employees
ADD Bonus_Salary varchar(255);
Comments
Leave a comment