怎么才能让列不能重复啊 急!!!急!!!急!!!
select distinct(i.inStoreNO) inStoreNO,
i.inStoreID,
st.storeName,
st.storeID store,
u.userName storeAdmin,
sp.supplierName supplier,
inDate
from InStore i
left join Store st on i.store=st.storeID
left join [User] u on i.storeAdmin=u.userID
left join Supplier sp on i.supplier=sp.supplierID
where 1=1 and i.store=15 and i.supplier=41 Order By inDate DESC
大哥,我等着回家 就这一个功能了
这次应该行了,能多给点分不:
select inStoreNO,inStoreID,storeName,store,storeAdmin,supplier,inDate
from
(
select i.inStoreNO inStoreNO,
i.inStoreID,
st.storeName,
st.storeID store,
u.userName storeAdmin,
sp.supplierName supplier,
inDate,
ROW_NUMBER() over(PARTITION by i.inStoreNO order by getdate()) rownum
from InStore i
left join Store st on i.store=st.storeID
left join [User] u on i.storeAdmin=u.userID
left join Supplier sp on i.supplier=sp.supplierID
where 1=1 and i.store=15 and i.supplier=41
)t
where rownum = 1
Order By inDate DESC