我收到错误子查询返回多个值 这是我的查询
SELECT d.Description ,s.Version , d.UtiPrefix , d.UTI , d.PrimaryAC , s.ReportingObb , s.ReportingObb , d.LEI , d.LEI_Countp , d.LEI , s.ReportingDeleg ,d.Curr , c.Trade_Party_Domicile ,c.LEI_SGR
, Price =( select Price
From Price
inner join Derivatives
on Derivatives.UTI = Price.UTI)
FROM Derivatives as d
INNER JOIN Settings as s
ON d.LEI_SGR = s.LEI_SGR
INNER JOIN Clients c
ON d.LEI_SGR = c.LEI_SGR
答案 0 :(得分:2)
使用相关子查询
Price =( select Price From Price p WHERE d.UTI = p.UTI)
答案 1 :(得分:1)
我怀疑这会返回多行
( select Price
From Price
inner join Derivatives
on Derivatives.UTI = Price.UTI )
为什么要将子查询与连接混合使用?
SELECT d.Description ,s.Version , d.UtiPrefix , d.UTI , d.PrimaryAC , s.ReportingObb
, s.ReportingObb , d.LEI , d.LEI_Countp , d.LEI , s.ReportingDeleg ,d.Curr
, c.Trade_Party_Domicile ,c.LEI_SGR
, p.Price
FROM Derivatives as d
INNER JOIN Settings as s
ON d.LEI_SGR = s.LEI_SGR
INNER JOIN Clients c
ON d.LEI_SGR = c.LEI_SGR
INNER JOIN Price p
ON p.UTI = d.UTI