上面语句的执行结果如下
200 2004-07-28 15:30:42.793 司磅员一 经手人二 林中华 NULL NULL
200 2004-07-28 15:40:19.573 司磅员一 经手人二 林中华 NULL NULL
我要的结果就需要一条
200 2004-07-28 15:30:42.793 司磅员一 经手人二 林中华 NULL NULL
200 2004-07-28 15:40:19.573 司磅员一 经手人二 林中华 NULL NULL
我要的结果就需要一条
调试欢乐多
还是另想办法了
SELECT DISTINCT Storage.cinStorageNo,
DISTINCT Storage.dstorageDate,
DISTINCT Storage.cweightman,
DISTINCT Storage.cHandleMan,
DISTINCT Storage.cgoodsmaster,
DISTINCT Storage.bsice,
DISTINCT Storage.Re
FROM Storage
试试!
select top 1 * from storage
FROM Storage DISTINCT后面只能跟一个字段
(select top 1 b.dstorageDate from Storage b where b.cinStorageNo = a.cinStorageNo)
...
from storage a
min(Storage.dstorageDate),
min(Storage.cweightman),
min(Storage.cHandleMan),
min(Storage.cgoodsmaster),
min(Storage.bsice),
min(Storage.Re)
FROM Storage
group by 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
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=上面语句取出的值
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
)