我想加入这两个查询。
我想要列FulliteName
,text
,BeginningBalance
,QuantityReceived
,DOS
,Loss
,RequestedQuantity
。
我尝试了以下查询。但只有第一部分被执行。
SELECT CI.ItemID,
FullItemName,
iub.UnitOfIssueID,
us.TEXT
FROM Commodity.ItemRRFGroup CI
INNER JOIN dbo.vwGetAllItems y
ON y.ID = ItemID
INNER JOIN ItemUnitBase iub
ON y.ID = iub.ID
INNER JOIN UnitOfIssue us
ON iub.UnitOfIssueID = us.ID
LEFT JOIN (
SELECT RD.RequestID,
y.RRGroupID,
y.PeriodID,
ItemID,
CONCAT (
Convert(DATE, StartDate),
' to ',
Convert(DATE, EndDate)
) Period,
BeginningBalance,
QuantityReceived,
DOS,
Loss,
RequestedQuantity
FROM RRF.RequestDetail RD
INNER JOIN RRF.Request y
ON y.RequestID = RD.RequestID
INNER JOIN RRF.Period x
ON x.PeriodID = y.PeriodID
INNER JOIN OrderDetail o
ON o.OrderID = y.orderID
) AS x
ON CI.ItemID = x.ItemID
答案 0 :(得分:3)
也许你改变了这个:
Select
CI.ItemID,
FullItemName,
iub.UnitOfIssueID,
us.text
.....
对此:
Select
CI.ItemID,
FullItemName,
iub.UnitOfIssueID ,
us.text,
x.BeginningBalance,
x.QuantityReceived,
x.DOS,
x.Loss,
x.RequestedQuantity
....
<强>更新强>
如果您不使用子查询的别名x。然后你不会从x获取列。