SQL Queries SIR
SQL Queries SIR
Worker table.
select *
from Worker
-- Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME
Ascending and DEPARTMENT Descending.
Select *
from Worker
-- Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME
Ascending.
Select *
from Worker
-- Write an SQL query to print the FIRST_NAME and LAST_NAME from Worker table into a single
column COMPLETE_NAME. A space char should separate them.
from Worker;
-- Write an SQL query to print the FIRST_NAME from Worker table after replacing ‘a’ with ‘A’.
select REPLACE(FIRST_NAME,'a','A')
from Worker;
-- Write an SQL query that fetches the unique values of DEPARTMENT from Worker table and prints
its length.
-- Write an SQL query to print the first three characters of FIRST_NAME from Worker table.
select SUBSTRING(FIRST_NAME,1,3)
from Worker;
-- Write an SQL query to fetch unique values of DEPARTMENT from Worker table.
from Worker;
-- Write an SQL query to fetch “FIRST_NAME” from Worker table in upper case.
select UPPER(FIRST_NAME)
From Worker;
-- Write an SQL query to fetch “BONUS_AMOUNT” and "BONUS_DATE" from the Bonus table.
select BONUS_AMOUNT,BONUS_DATE
from Bonus;
-- Write an SQL query to fetch “FIRST_NAME” from Worker table using the alias name as
<WORKER_NAME>.
from Worker;
select LAST_NAME
from Worker;
select *
from Worker;
-- get the departments where the average salary is greater than the average company salary
from Worker
Group by DEPARTMENT
Select avg(SALARY)
From Worker;
from Worker
Group by DEPARTMENT;
-- Write an SQL query to fetch the departments that have less than four people in it.
from Worker
Group by DEPARTMENT
-- Write an SQL query to fetch the no. of workers for each department in the descending order.
from Worker
Group by DEPARTMENT
-- Write an SQL query to fetch worker names with salaries >= 50000 and <= 100000.
from Worker
where SALARY IN
(Select SALARY from Worker where SALARY between 50000 and 100000);
-- Write an SQL query to fetch the names of workers who earn the highest salary.
From Worker
-- Write an SQL query to print details of the Workers who are also Managers.
from Worker
FROM Worker
FROM Worker
-- Write an SQL query to fetch the count of employees working in the department ‘Admin’.
select count(DEPARTMENT)
from Worker
select *
from Worker
-- Write an SQL query to print details of the Workers whose SALARY lies between 100000 and
500000.
select *
from Worker
-- Write an SQL query to print details of the Workers whose FIRST_NAME ends with ‘h’ and contains
six alphabets.
select *
from Worker
-- Write an SQL query to print details of the Workers whose FIRST_NAME contains ‘a’.
select*
from Worker
-- Write an SQL query to print details of Workers with DEPARTMENT name as “Admin”.
select *
from Worker
-- Write an SQL query to print details of workers excluding first names, “Vipul” and “Satish” from
Worker table.
select *
from Worker
-- Write an SQL query to print details for Workers with the first name as “Vipul” and “Satish” from
Worker table.
select *
from Worker
-- Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME
Ascending and DEPARTMENT Descending.
select *
from Worker
-- Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME
Ascending.
select *
from Worker