select distinct id,zd1,zd2,zd3 from 表

解决方案 »

  1.   

    错了.应该是select min(id) id, zd1,zd2,zd3 from 表 group by zd1,zd2,zd3
      

  2.   

    select min(id) as id, zd1,zd2,zd3 from 表 group by zd1,zd2,zd3
      

  3.   

    create table tb(id int, zd1 int, zd2 int, zd3 int)
    insert into tb values(1 ,  111, 222,  333)
    insert into tb values(2 ,  444, 555,  666)
    insert into tb values(3 ,  111, 222,  777)
    insert into tb values(4 ,  111, 222,  333)
    insert into tb values(5 ,  888, 555,  666)
    insert into tb values(6 ,  444, 555,  666)
    select min(id) id, zd1,zd2,zd3 from tb group by zd1,zd2,zd3 order by id
    drop table tb/*
    id          zd1         zd2         zd3         
    ----------- ----------- ----------- ----------- 
    1           111         222         333
    2           444         555         666
    3           111         222         777
    5           888         555         666(所影响的行数为 4 行)
    */