1. Write Max salary from each department
Select max(SALARY) from employee group by
department
2. Select Distinct employee name whose salary between 3000 to 3500
Select DISTINCT(firstName) from employee where SALARY
between 3000 AND 3500
3. Write a query to find employee whose salary is is equal or greater than 40000?
Select * from employee where SALARY>=40000
4. Write a
Query to find a name of employee whose name start with ‘S’;
Select * from employee where firstName like ‘S%’
5. Write a query to find maximum salary for a lady employee
Select * from employee where SALARY IN(select
MAX(SALARY) from employee where GENDER=’FEMALE’)
6. Write a query to find 3rd highest salary
Select Top 1 SALARY as ‘3rd highest
salary’ from(select Top 3 salary from employee ORDER BY SALARY DESC) ORDER BY ASC
7. Write a
query to get 3rd lowest salary
Select Top 1 SALARY as ‘3rd lowest salary’ from (Select DISTINCT Top 3 SALARY from employee ORDER BY SALARY ASC) ORDER BY SALARY DESC
8. Write a query to update salary of an employee Yashika to 34000
Update employee SET SALARY=34000 where FIRSTNAME =
‘Yashika’ and LASTNAME = ‘Reddy’
9. Write a query to delete employee details named Deepak
Delete from employee
where FIRSTNAME = ‘deepak’;
10. Write a query to fetch all details from
both Employee and Company details
Select * from employee, Company
WHERE employee.EMP_ID=Company.Employee_Id
11. Write a query inner join on Employee and
Company details
Select * from employee INNER JOIN Company ON employee.EMP_ID=Company.Employee_Id
12. Write a query Outer join on Employee and
Company details
Select * from employee FULL JOIN Company ON employee.EMP_ID=Company.Employee_Id
13. Write a query to fetch
company name of the lady employee who is getting highest
salary?
Select cmp.COMPANY_NAME
From employee emp FULL JOIN Company cmp ON emp.EMP_ID=cmp.Employee_Id
WHERE emp.SALARY IN(SELECT
MAX(SALARY) from employee where gender=’Female’);
14. Write a query to Create a table and drop
same table?
DROP table employee
15. Count the employees departments wise?
Select department_id, count(*), from employee group by department_id
No comments:
Post a Comment