Q-1. Write an SQL query to fetch “FIRST_NAME” from Worker table using the alias name as <WORKER_NAME>.
SELECT FIRST_NAME AS WORKER_NAME FROM WORKERS;
Q-2. Write an SQL query to fetch unique values of DEPARTMENT from Worker table.
SELECT DISTINCT DEPARTMENT FROM WORKERS;
Q-3. Write an SQL query to show the last 5 record from a table.
SELECT * FROM WORKERS
WORKER_ID > (SELECT COUNT(*) FROM WORKERS)-5 ;
Q-1. Write an SQL query to print the first three characters of FIRST_NAME from Worker table.
Q-2. Write an SQL query to find the position of the alphabet (‘a’) in the first name column ‘Amitabh’ from Worker table.
Select CHARINDEX('a', 'Amitabh') as Position;
Q-3. Write an SQL query to print the name of employees having the highest salary in each department.
SELECT t.DEPARTMENT,t.FIRST_NAME,t.Salary from(SELECT max(Salary) as TotalSalary,
DEPARTMENT from WORKERS group by DEPARTMENT) as TempNew
Inner Join WORKERS t on TempNew.DEPARTMENT=t.DEPARTMENT