一个表中有三个字段。A,B,C。。查询A不同,B、C相同的数据

解决方案 »

  1.   

    select * from tableA where b=c and a<>b;
      

  2.   

    select a.* from tableA a,tableA b where a.b=b.b and a.c=b.c  and a.a<>b.a
      

  3.   

    不好意思啊。我没有说明白。。我的意思是,比如有两条这样的数据
    A B C
    1 1 3
    2 1 3
    3 1 2
    现在要查出前两条
      

  4.   

    oracle有专门函数没有。。2楼的效率怎么样。
      

  5.   

    select * from v_table where a <> b and b = c;
      

  6.   

    select t.a,t.b,t.c from (select a,b,c,rownum rn from Table_test order by a) t where t.rn<=2;
      

  7.   

    select t.a,t.b,t.c from 
          (select a,
                  b,
                  c,
                  count(rownum) rn over (partition by b,c group by b,c)) t
       where t.rn>1;
      

  8.   

    select a, b, c
      from (select a,
                   b,
                   c,
                   row_number() over(partition by b, c order by rowid) rn
              from tablename)
     where rn > 1;
      

  9.   

    --少写了表名:select t.a,t.b,t.c from 
          (select a,
                  b,
                  c,
                  count(rownum) rn over (partition by b,c group by b,c)
                from table_test) t
       where t.rn>1;
      

  10.   

    select a.A,a.B,a.C from tables a,tables b where a.B=b.B and a.C=b.C  and a.A<>b.A