如何过滤掉含有null的记录
oracle 中的有如下的表
EMPNO ENAME SAL deptno
------ ------ ---- ------
7900 JAMES 800
7902 FORD 1600 10
7934 MILLER 1700 20
1000 Mary 6000 30
7369 SMITH 2850 20
7499 ALLEN 3000 20
7521 WARD 2970 10
7566 JONES 3400 30
7654 MARTIN 2500 10
7698 BLAKE 1900 30
7782 CLARK 2200 20
7788 SCOTT 900 10
现要求统计每个部门工资排在前3位的员工,不包括总经理Mary,她的部门为空
我写的语句如下,但是却不能过滤掉含有Mary的那条记录.
select e1.ename,e1.sal,e1.deptno from t_emp e1
where(select count(distinct e2.sal) from t_emp e2
where e1.deptno=e2.deptno and e1.deptno is not null and
e1.sal <e2.sal)
<3;
请各位大侠指教!
------解决方案--------------------select e1.ename,e1.sal,e1.deptno from biao e1
where(select count(distinct e2.sal) from biao e2
where e1.deptno=e2.deptno and e1.deptno is not null and
e1.sal <e2.sal)
<3 and e1.deptno is not null;