1. Query all employees whose department number is 30
select * from wrc where deptno;
2. The names, numbers and department numbers of all salespersons.
select ename,job,deptno from wrc;
3. Identify employees whose bonuses are higher than their salary.
select * from wrc where comm>sal;
4. Identify employees whose bonuses are 60% higher than their salary .
select * from wrc where comm >sal*0.6;
5. Find out the details of all managers in department number 10 and all salesmen in department number 20.
select * from wrc where deptno = 10 and job ="经理" or job = "销售员"and deptno =20;
6. Find the details of all managers in department number 10 , all salesmen in department number 20 , and all employees who are neither managers nor salesmen but whose salary is greater than or equal to 20,000 .
select * from wrc where deptno = 10 and job ="经理" or job = "销售员"and deptno =20 or sal>20000 and job <>"经理" and job<>"销售员";
7. Employees with no bonus or bonus less than 1000 .
select * from wrc where comm between 0 and 1000;
或者 select * from wrc where comm<1000 and comm >=0;
8. Query employees whose names consist of three characters.
select * from wrc where ename like "___";
9. Check the employees who joined in 2000 .
select * from wrc where hiredate like "2000%";
10. Query all employee details, sort by number in ascending order
select * from wrc order by empno desc;
11. Query the details of all employees, sort by salary in descending order, if the salary is the same, use the entry date to sort in ascending order
select * from wrc order by sal desc,hiredate asc;
12. Query employees with two first names surnamed Zhou.
select * from wrc where ename like "周%";
13. Query all employees with the surname Zhang.
select * from wrc where ename like "张%";
14. Check how many positions there are in the department and how many people there are in each position.
select count(job),job from wrc group by job;
15. Check which position has more than 3 people .
select count(job),job from wrc group by job having count(job)>3;