如 表中记录是
    code   serialno
    A1       1
    A1       2
    A1       3
    A1       5    B1       2
    B1       3
    B1       4  我需要的结果是 表中 A1和B1的第2条记录.

解决方案 »

  1.   

    select 
        a.code,a.serialno
    from
        (select code,serialno,rownum rid from 表) a,
        (select code,serialno,rownum rid from 表) b
    where
        a.code=b.code and a.rid>=b.rid
    group by
        a.code,a.serialno
    having count(*)=2
      

  2.   

    libin_ftsafe(子陌红尘):
    太感谢了,我用你的方法试成功了。
    不过有些看不懂。 能解释一下吗?谢谢
      

  3.   

    对表中的记录利用rownum编号,然后利用两个子查询对同一条记录的编号相同的原理,统计code相同的记录存在几条编号小于等于当前编号的记录,如果为2,则说明当前记录在表中对于相同的code是第二条记录,输出