Q-1. Write an SQL query to print the FIRST_NAME from Worker table after removing white spaces from the right side.
SELECT RTRIM(FIRST_NAME) AS NAME FROM WORKERS;
Q-2. Write an SQL query that fetches the unique values of DEPARTMENT from Worker table and prints its length.
SELECT DISTINCT LEN (DEPARTMENT) FROM WORKERS;
Q-3. Write an SQL query to fetch nth max salaries from a table.
SELECT TOP 1 SALARY FROM ( SELECT DISTINCT TOP 1 salary FROM WORKERS ORDER BY salary DESC )
AS temp ORDER BY salary
Q-1. Write an SQL query to print the FIRST_NAME from Worker table after replacing ‘a’ with ‘A’.
SELECT REPLACE(FIRST_NAME,'a','A') FROM WORKERS
Q-2. Write an SQL query to print all Worker details from the Worker table order by FIRST_NAME Ascending and DEPARTMENT Descending.
SELECT FIRST_NAME,DEPARTMENT FROM WORKERS ORDER BY FIRST_NAME ASC,DEPARTMENT DESC;
Q-3. Write an SQL query to fetch the names of workers who earn the highest salary.
SELECT FIRST_NAME, SALARY from WORKERS WHERE SALARY=(SELECT max(SALARY) from WORKERS);
Q-1. Write an SQL query to print details of workers excluding first names, “Vipul” and “Satish” from Worker table.
SELECT FIRST_NAME FROM WORKERS where FIRST_NAME NOT IN ('Vipul','Satish') ;
Q-2. Write an SQL query to print details of the Workers whose FIRST_NAME ends with ‘h’ and contains six alphabets.
SELECT * FROM WORKERS WHERE FIRST_NAME LIKE '______H'
Q-3. Write a query to validate Email of Employee.
SELECT * FROM WORKERS
WHEN EMAIL LIKE '%[email protected]_%._%' THEN 'VALID'