select * from employee
select * from department
--display top 3 records from employee table.
select top 2 * from employee where emp_id < (select max(emp_id) from employee) order by emp_salary desc
select * from employee order by emp_salary asc
--dispaly sum of salary of those employees who are working in Marketing department
select sum(emp_salary) from employee e inner join department d on d.dept_id=e.dem_deptid
where d.dept_name='Marketing'
--display top 5 records of employees who are working in Hr and Marketing
select top 5 * from employee e inner join department d on d.dept_id=e.dem_deptid
where d.dept_name='Marketing' or d.dept_name='Hr'
No comments:
Post a Comment