Professional Documents
Culture Documents
select*from Employee;
select*from Employee_bonus;
select* from employee_title;
Tasks To Be Performed:
Display the “FIRST_NAME” from Employee table using the alias name as Employee_name.
Syntax:
select first_name employee_name from Employee;
5. Display the unique values of DEPARTMENT from EMPLOYEE table and prints its
length.
Syntax:
select distinct (department),len(department) from Employee;
6. Display the FIRST_NAME and LAST_NAME from EMPLOYEE table into a single column AS
FULL_NAME.
Syntax:
select first_name+last_name as Full_Name from employee;
7. DISPLAY all EMPLOYEE details from the employee table order by FIRST_NAME
Ascending.
Syntax:
select* from employee order by(First_Name);
9. Display details for EMPLOYEE with the first name as “VEENA” and “KARAN” from
EMPLOYEE table.
Syntax:
select * from employee where First_Nam in (‘Veena’,’Karan’);
14. Display employee names with salaries >= 50000 and <= 100000.
Syntax:
select First_Name, Salary from Employee where Salary>= 50000 and Salary<= 100000
17. DISPLAY duplicate records having matching data in some fields of a table.
Syntax:
select department count from Employee group by Department having count(*)>1
24. Display the departments that have less than 4 people in it.
Syntax:
select department from Employee group by Department
having count(*)< 4
25. Display all departments along with the number of people in there.
Syntax:
select department, count(*) from Employee
group by Department
26 Display the name of employees having the highest salary in each department.
Syntax:
select first_name, salary, department from Employee
where Salary in(
select max(salary) from Employee
group by Department);
29 display the name of the employee who has got maximum bonus.
Syntax:
select E.first_name, E.last_name, B.amount from dbo.Employee E
INNER JOIN
(select Emp_ID, Amount, row_number() over (order by Amount desc) RN_Bonus from
dbo.Employee_Bonus )B
on E.Employee_ID = B.Emp_ID
where B.RN_Bonus = 1
30. Display the first name and title of all the employees.
Syntax:
select E.first_name, T.Emp_Title from dbo.Employee E
Inner join
(select Emp_ref_ID, EMP_Title from dbo.Employee_Title )T
on E.Employee_ID=T.Emp_ref_ID
THANK YOU.