试一下这样:
sql=select piaohao,name from xtp_1 where time=2006 group by piaohao,name 

解决方案 »

  1.   

    不行,那样得到的piaohao,name是有重复的
    得到的就是200645         中国
              200645         中国
    相同的记录我只要一个就行
    group by piaohao,name 就能把相同的记录去掉吗?、
      

  2.   

    select distinct piaohao,name from xtp_1 where time=2006
      

  3.   

    你有试过吗?
    NAME ID SALARY
    Zeng 123456 99
    Jacob 1314 101
    AB 1314 100
    AB 1314 100
    执行下面SQL:
    select name,salary from test2  where id=1314 group by name,salary
    结果:
    NAME SALARY
    AB 100
    Jacob 101
      

  4.   

    sql=
    select distinc(piaohao) piaohao,(select max(name) from xtp_1 where piaohao=t1.piaohao)name from xtp_1 t1 where time=2006
      

  5.   

    select piaohao,name from (select min(piaohao),min(name) from xtp_1 where time=2006 group by piao)
      

  6.   


    这样写可以,你试一下select piaohao,name from (select min(piaohao),min(name) from xtp_1 where time=2006 group by piao)
      

  7.   

    sql=select piaohao,name from xtp_1 where time=2006 group by piaohao,name 
    不能??? 
    不会吧
      

  8.   

    select piaohao,name from xtp_1 where time=2006 group by piaohao,name
    select distinct piaohao,name from xtp_1 where time=2006这两种应该都可以的吧
      

  9.   

    试试我这个
    Select t.piaohao, t.name
      From (select piaohao,
                   name,
                   Row_Number() Over(Partition By piaohao, name Order by Rownum) As RId
              From xtp_1) t
     Where t.RId = 1
      

  10.   

    select piaohao,name from xtp_1 where time=2006 group by piaohao,name 或
    select distinct piaohao,name from xtp_1 where time=2006