创建一个自定义列

时间:2019-07-18 00:49:15

标签: sql

我正在尝试创建一个自定义列,该列是2个现有列的乘积。

(
  select
    omdDeliveryQty * omlUnitPriceBase AS 'Value'
) *
from
  SalesOrderDeliveries
  Left Outer Join SALESORDERLINES On OMDSALESORDERID = OMLSALESORDERID
  And OMDSALESORDERLINEID = OMLSALESORDERLINEID

1 个答案:

答案 0 :(得分:0)

您可能想要:

select
  *,
  d.omdDeliveryQty * l.omlUnitPriceBase AS 'Value'
from SalesOrderDeliveries d
left outer join SALESORDERLINES l
  on d.OMDSALESORDERID = l.OMLSALESORDERID 
 and d.OMDSALESORDERLINEID = l.OMLSALESORDERLINEID

别忘了为每个表添加别名(我添加了dl),以使查询更易于阅读和调试。