上面语句的执行结果如下
200 2004-07-28 15:30:42.793 司磅员一 经手人二 林中华 NULL NULL
200 2004-07-28 15:40:19.573 司磅员一 经手人二 林中华 NULL NULL
我要的结果就需要一条

解决方案 »

  1.   

    看用distinct是不行了
    还是另想办法了
      

  2.   


    SELECT DISTINCT Storage.cinStorageNo,   
           DISTINCT  Storage.dstorageDate,   
           DISTINCT  Storage.cweightman,   
           DISTINCT  Storage.cHandleMan,   
           DISTINCT  Storage.cgoodsmaster,   
           DISTINCT  Storage.bsice,   
           DISTINCT  Storage.Re  
        FROM Storage   
    试试!
      

  3.   

    最简单的取一条数据:
    select top 1 * from storage
      

  4.   

    SELECT DISTINCT Storage.cinStorageNo
        FROM Storage DISTINCT后面只能跟一个字段
      
      

  5.   

    select distinct a.cinStorageNo,   
     (select top 1 b.dstorageDate from Storage b where b.cinStorageNo = a.cinStorageNo)
    ...
    from storage a   
      

  6.   

    SELECT   Storage.cinStorageNo,   
             min(Storage.dstorageDate),   
             min(Storage.cweightman),   
             min(Storage.cHandleMan),   
             min(Storage.cgoodsmaster),   
             min(Storage.bsice),   
             min(Storage.Re)  
        FROM Storage   
        group by cinStorageNo
      

  7.   

    select distinct a.cinStorageNo,   
     (select top 1 b.dstorageDate,b.cweightman,b.cHandleMan,b.cgoodsmaster,b.bsice,b.Re  , from Storage b where b.cinStorageNo = a.cinStorageNo)
    from storage a
      

  8.   

    SELECT DISTINCT Storage.cinStorageNo,   
             Storage.dstorageDate,   
             Storage.cweightman,   
             Storage.cHandleMan,   
             Storage.cgoodsmaster,   
             Storage.bsice,   
             Storage.Re  
        FROM Storage   
    ////由于Storage.dstorageDate值存在不同所以会出现两条记录
    建议先把Storage.dstorageDate字段在sql语句中剔除,
    SELECT DISTINCT Storage.cinStorageNo,   
             Storage.cweightman,   
             Storage.cHandleMan,   
             Storage.cgoodsmaster,   
             Storage.bsice,   
             Storage.Re  
        FROM Storage   
    如果确实需要,在重新写一个sql语句
    select Storage.dstorageDate from storage where Storage.cinStorageNo=上面语句取出的值
      

  9.   

    SELECT   Storage.cinStorageNo,   
             Storage.dstorageDate,   
             Storage.cweightman,   
             Storage.cHandleMan,   
             Storage.cgoodsmaster,   
             Storage.bsice,   
             Storage.Re  
        FROM Storage  
        where Storage.cinStorageNo in (select min(Storage.cinStorageNo),Storage.dstorageDate,   
             Storage.cweightman,   
             Storage.cHandleMan,   
             Storage.cgoodsmaster,   
             Storage.bsice,   
             Storage.Re
         from storge group by Storage.dstorageDate,   
             Storage.cweightman,   
             Storage.cHandleMan,   
             Storage.cgoodsmaster,   
             Storage.bsice,   
             Storage.Re  
       )