emp表有emp_no,emp_idn(员工职位,有01,02),dept字段,要列出同一dept内超过1个员工职位是02的dept及其职员信息

解决方案 »

  1.   

    select *
    from emp
    where dept in(
    select dept
    from emp
    where emp_idn='02'
    group by dept
    having count(*)>1)
      

  2.   


    select * from emp where dept in
    (select dept from emp where emp_idn = '02' group by dept having count(*) > 1)
      

  3.   


    select tt.*
        from (
        select t.*
               RANK() OVER (PARTITION BY t.dept order by rownum) Rnk 
        from emp t
        where t.emp_idn = 02---员工职位是02
        )tt
        where tt.rnk >= 2lz可以参考一下上边的思路.应该可以实现你的要求.
      

  4.   

    SELECT *
      FROM (SELECT DEPT, EMP_IDN, COUNT(EMP_IDN) OVER(PARTITION BY EMP_IDN) GS
              FROM EMP
             WHERE DEPT = '某个部门')
     WHERE GS > 1