有一个表A(a,b,c,d,e)记录有:
a1,b1,c1,d1,e1
a2,b1,c1,d1,e1
a3,b1,c1,d1,e2
a4,b2,c1,d1,e3
a5,b2,c1,d1,e3
a6,b2,c1,d1,e3将b,c,d,e 相同的记录去掉。怎么样写

解决方案 »

  1.   


    select a,b,c,d,e from (
           select a,b,c,d,e,row_number()over(partition by b,c,d,e order by a) rn
           from A
    )
    where rn=1;
      

  2.   

    a1,b1,c1,d1,e1
    a2,b1,c1,d1,e1
    比如说这里条吧,你说的去掉是把两条都去掉呢,还是去掉其中的一天啊?
      

  3.   

    select *
    from tb where rowid in(select max(rowid) from tb group by b,c,d,e)
      

  4.   

    --把两条都去掉
    select b,c,d,e from (
           select b,c,d,e,count(a) rn
           from A
           group by b,c,d,e
    )
    where rn=1;
      

  5.   

    (select a,b,c,d row_number()over(partition by b,c,d order by a) 这个是什么意思啊 可以解释一下么?
      

  6.   

    分析函数 按b,c,d分组 然后按a排序 给这些定好的记录加个序号
    a b c d
    1 2 2 2
    2 2 2 2
    3 1 1 1
    3 1 1 1
    2 3 3 3--结果这样
    a b c d  row_number()over(partition by b,c,d order by a) rn
    1 2 2 2  1
    2 2 2 2  2
    3 1 1 1  1
    5 1 1 1  2
    2 3 3 3  1 
      

  7.   

    select deptno,ename,row_number() over(partition by deptno order by ename) rn
    from emp
    把这个拿去运行下就知道了
      

  8.   

    select deptno,ename,row_number() over(partition by deptno order by ename) rn
    from emp
    把这个拿去运行下就知道了
      

  9.   

    delete from A where a=
    ( select a from(
      select a,b,c,d,e,count()over(partition by b,c,d,e) tot from A) B
    where B.tot>=2
    )
      

  10.   

    delete from A  t1 where 
    exists(select 1 from A t2 where t1.b = t2.b and t1.c = t2.c and t1.d = t2.d
     and t1.e = t2.e and t1.a <> t2.a)