读书人

Id列如何无效,求大侠解答

发布时间: 2014-01-15 15:40:23 作者: rapoo

Id列怎么无效,求大侠解答

select type 出入库,storeNO 单据编号,ID,store 仓库名称,storeAdmin 库管员,source,storeDate 日期,price 金额 from
((select type,storeNO,store,storeAdmin,source,storeDate,SUM(price) price
from
(select 'out' type,o.outStoreNO storeNO,st.storeName store, st.storeID ID,
u.userName storeAdmin,c.canteenName source,o.outDate storeDate,
case when p.quantity=0 then p.quantity else o.outQuantity*(p.price/p.quantity) end price
from OutStore o
left join Store st on o.store=st.storeID
left join [User] u on o.storeAdmin=u.userID
left join Canteen c on o.canteen=c.CanteenID
left join(select * from StoreQuantity s left join Product pro on s.product=pro.productID where s.store=2) p
on o.product=p.productID where o.store=2 ) ou
group by type,storeNO,store,storeAdmin,source,storeDate)
union
(select type,storeNO,store,storeAdmin,source,storeDate,SUM(price) price
from
(select 'in' type,i.inStoreNO storeNO,st.storeName store,st.storeID ID,
u.userName storeAdmin,sp.supplierName source,i.inDate storeDate,
inPrice price
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 i.store=2) as i
group by type,storeNO,store,storeAdmin,source,storeDate)) sr where 1=1 order by storeDate DESC

[解决办法]
引用:

Quote: 引用:

重复了!没指名是那个表的ID!

那怎么办啊


第二行和第四行字段没对应上吧~你检查一下!

读书人网 >SQL Server

热点推荐