insert into a(a,b,c,d)
select distinct a,b,c,d from c 

解决方案 »

  1.   

    select distinct a,b,c,d from c 可是我这里只能查询出一条select  a,b,c,d from c 
    这样的确有两条一样的数据。
    请问要怎样改?
      

  2.   

    select distinct a,distinct b,distinct c,distinct d from c
      

  3.   

    不好意思  刚刚写错了 这个问题是因为你b,c,d字段的值不一样  必须要用聚合函数来处理一下 比如  max(b),max(c),max(d)
      

  4.   


    create table t1(a varchar2(10),b varchar2(10),c varchar2(10),d varchar2(10));
    create table t2(a varchar2(10),b varchar2(10),c varchar2(10),d varchar2(10));
    insert into t1 values('a','b','c','d');
    insert into t1 values('a','b','c','d');
    commit;
    insert into t2 select distinct a,b,c,d from t1;
    SQL> select * from t2;
     
    A          B          C          D
    ---------- ---------- ---------- ----------
    a          b          c          d
      

  5.   

    难道是灵异事件么? 你查询的DISTINCT 肯定是两条.
      

  6.   

    你select top 1 试试呢
      

  7.   

    我也搞不懂
    insert into a(a,b,c,d)
    select distinct * from( select distinct a,b,c,d from c)  我想到一个原因就是 
    select distinct a,b,c,d from c
    有些列没有指定列名
      

  8.   

    你要明白distinct的用法:如:a   b  c   d
    ------------------
       1    2   3  4
       1    2   3  5
       1    2   3  6
       2    3   4  6
       3    4   5  7
    --对 a b c d四个字段取唯一值,这样取出来是3条数据
    select distinct a,b,c,d from table001;
       a   b  c   d
    ------------------
       1    2   3  4
       1    2   3  5
       1    2   3  6--对a单独取唯一值
    select count(distinct a) countA from table001 group by a;
        countA
    ------------------
           3
      

  9.   

    你试下group by a,b,c,d看下,查询出来是几条数据。