ここでクエリを処理していますが、サブアイテム列に複数のサブアイテムがあります。 1つのサブアイテムのみを表示するようにクエリを調整したい。私が持っているPOテーブルには、複数のサブアイテムがある場合とない場合があります。SQL Select Distinct
SELECT
dbo.MasterTable.StartItem,
dbo.MasterTable.SubItem,
dbo.MasterTable.STDCOST,
ISNULL(dbo.PO_2_months.[Purchase Price], dbo.MasterTable.STDCOST) AS NewCost,
dbo.PO_2_months.[Purchase Price]
FROM dbo.MasterTable LEFT OUTER JOIN
dbo.PO_2_months ON dbo.MasterTable.SubItem = dbo.PO_2_months.Item
GROUP BY
dbo.MasterTable.SubItem,
dbo.MasterTable.STDCOST,
ISNULL(dbo.PO_2_months.[Purchase Price], dbo.MasterTable.STDCOST),
dbo.MasterTable.StartItem,
dbo.PO_2_months.[Purchase Price]
HAVING (dbo.MasterTable.StartItem = 'FO6534')
複数の副明細の場合、どの副明細が必要ですか?最初の1つ? – danihp