Query
Query
Select distinct Salary from Employee e1 where 2=Select count (distinct Salary) from Employee e2 where
e1.salary<=e2.salary;
Alternative Solution:
Select min (salary) from (select distinct salary from emp order by salary desc) where rownum<=2;
How can i create table with same structure with data of Employee table?
Create table Employee1 as select * from Employee;
Write a Query to get information of Employee where Employee is not assigned to the department ?
Select * from Employee where Dept_no Not in(Select Department_no from Employee);
How to get distinct records from the table without using distinct keyword?
Select * from Employee a where rowid = (select max (rowid) from Employee b where
a.Employee_no=b.Employee_no);
Select all records from Employee table whose name is ‘Amit’ and ‘Pradnya’
Select * from Employee where Name in(‘Amit’,’Pradnya’);
Select all records from Employee table where name not in ‘Amit’ and ‘Pradnya’
Select * from Employee where name Not in (‘Amit’,’Pradnya’);
How to fetch all the records from Employee who’s joining year is 2017?
Answer: Oracle:
Select * from Employee where To_char(Joining_date,’YYYY’)=’2017′;
How do you find all Employees with its managers? (Consider there is manager id also in Employee table)
Select e.employee_name,m.employee name from Employee e,Employee m where e.Employee_id=m.Manager_id;
Display the name of employees who have joined in 2016 and salary is greater than 10000?
Select name from Employee where Hire_Date like ‘2016%’ and salary>10000;