select
d.Name as Storage,
b.ID as GoodsID,
b.InputCode,
b.Name as GoodsName,
c.Name as Unit,
SUM(a.Number/c.UnitRate) as Number
from
Storage_Goods a,
Base_Goods b,
Base_Unit c,
(SELECT ID,Name
FROM Base_Storage
WHERE Lvl LIKE @StorageLvl AND Tag = '0') d,
(SELECT ID,Name
FROM Base_GoodsType
WHERE Lvl LIKE @GoodsLvl AND Tag = '0') e
where
a.GoodsID = b.ID
and a.StorageID = d.ID
and a.Number > @MinNumber
and c.MainID = b.ID
and b.GoodsTypeID = e.ID
and (c.Name = @OtherUnit)--这句改为 (c.Name in @OtherUnit)
group by d.Name,b.Id,b.InputCode,b.Name,c.Name
Order by d.Name,b.InputCode
select
d.Name as Storage,
b.ID as GoodsID,
b.InputCode,
b.Name as GoodsName,
c.Name as Unit,
SUM(a.Number/c.UnitRate) as Number
from
Storage_Goods a,
Base_Goods b,
Base_Unit c,
(SELECT ID,Name
FROM Base_Storage
WHERE Lvl LIKE @StorageLvl AND Tag = '0') d,
(SELECT ID,Name
FROM Base_GoodsType
WHERE Lvl LIKE @GoodsLvl AND Tag = '0') e
where
a.GoodsID = b.ID
and a.StorageID = d.ID
and a.Number > @MinNumber
and c.MainID = b.ID
and b.GoodsTypeID = e.ID
and charindex(c.Name, @OtherUnit)>0
group by d.Name,b.Id,b.InputCode,b.Name,c.Name
Order by d.Name,b.InputCode
select
d.Name as Storage,
b.ID as GoodsID,
b.InputCode,
b.Name as GoodsName,
c.Name as Unit,
SUM(a.Number/c.UnitRate) as Number
from
Storage_Goods a,
Base_Goods b,
Base_Unit c,
(SELECT ID,Name
FROM Base_Storage
WHERE Lvl LIKE @StorageLvl AND Tag = '0') d,
(SELECT ID,Name
FROM Base_GoodsType
WHERE Lvl LIKE @GoodsLvl AND Tag = '0') e
where
a.GoodsID = b.ID
and a.StorageID = d.ID
and a.Number > @MinNumber
and c.MainID = b.ID
and b.GoodsTypeID = e.ID
and (c.Name = @OtherUnit)
group by d.Name,b.Id,b.InputCode,b.Name,c.Name
Order by d.Name,b.InputCode