尝试仅返回第一个供应商代码,并使所有其他字段不受影响。
`Select
Container.Part_Key,
Part.Part_No,
Part.Name,
Part.Revision,
Container.Quantity,
Container.Container_Status,
OP.Operation_No,
Opp.Operation_Code,
Part.Part_Status,
Supplier.Supplier_Code
From Part_v_Container as Container
Join Part_v_Part as Part
ON Part.Part_Key = Container.Part_Key
Join Part_v_Part_Operation as Op
On Op.Part_Operation_Key = Container.Part_Operation_Key
Join Part_v_Operation as OPP
On OPP.Operation_Key = OP.Operation_Key
Join part_v_approved_supplier as Approved
On Approved.part_key = container.part_key
Join common_v_Supplier as Supplier
On Supplier.supplier_no = Approved.Supplier_No
Where Container.Active = '1'
group by container.part_key`
会有重复的部件号,修订版等。不担心。我只是希望零件号只列出最右边的一个经批准的供应商,即使对于任何给定的部件,数据库中列出了多个已批准的供应商。 此外,数据库列出批准的供应商的顺序无关紧要。
谢谢!
答案 0 :(得分:0)
在选择列表中添加子查询
(选择前1名supplier.supplier_code 来自供应商 其中Supplier.supplier_no = Approved.Supplier_No order by Supplier.supplier_no)作为供应商代码
这可以是选择列表中的最后一个字段 您可以按照添加适当的订单。
这适用于SQL Server