SQL - 将两列相乘并生成第三列不起作用

时间:2018-04-13 08:59:49

标签: sql multiplying

SELECT 
  PURCHASE_HEAD.PURCHASENO, 
  PURCHASE_HEAD.NAMN, 
  PURCHASE_ITEMS.ARTNUM, 
  PURCHASE_ITEMS.PURCHASEROW, 
  PURCHASE_HEAD.KONTO, 
  PURCHASE_ITEMS.ANTAL, 
  PURCHASE_ITEMS.ENHET, 
  PURCHASE_ITEMS.PRISENHET, 
  PURCHASE_HEAD.LEVERANT, 
  PURCHASE_HEAD.ADDRESS, 
  PURCHASE_HEAD.LEVERANTADDRESS, 
  PURCHASE_HEAD.LEVERANTADDRESS2, 
  PURCHASE_HEAD.LEVERANTPOSTNR, 
  PURCHASE_HEAD.LEVERANTPOSTORT, 
  PURCHASE_HEAD.POSTORT, 
  PURCHASE_HEAD.ADDRESS2, 
  PURCHASE_HEAD.POSTNR, 
  PURCHASE_HEAD.KONT1, 
  PURCHASE_HEAD.ADDRESS3, 
  PURCHASE_HEAD.POSTNR2, 
  PURCHASE_HEAD.POSTORT2, 
  PURCHASE_HEAD.OWN_NUMBER1, 
  PURCHASE_HEAD.DATUM, 
  PURCHASE_HEAD.LEVDATUM, 
  PURCHASE_HEAD.MOT, 
  PURCHASE_HEAD.BETALVILLKOR, 
  PURCHASE_HEAD.OVRIGT, 
  PURCHASE_ITEMS.LEVARTNUM, 
  PURCHASE_HEAD.BEST, 
  RP_VIEW_ANV_LOGIN_NAME_BEST.ANV_NAMN, 
  RP_VIEW_ANV_LOGIN_NAME_MOT.ANV_NAMN, 
  ANV.NAMN, 
  PURCHASE_HEAD.SIGN, 

Theese是我试图相互增加的两个专栏。

  PURCHASE_ITEMS.ANTAL * PURCHASE_ITEMS.ENHETSPRIS AS TOTALSUM,

并存储为TOTALSUM我不知道是什么导致它无法正常工作,我在微软查询中尝试了它并将结果放在一个空白的空白列中,但它实际上并没有创建一列

   PURCHASE_ITEMS.BENAMNING 
 FROM 
   {oj (
    (
      (
        PURCHASE_HEAD PURCHASE_HEAD 



        LEFT OUTER JOIN PURCHASE_ITEMS PURCHASE_ITEMS ON                                         
       PURCHASE_HEAD.PURCHASENO = PURCHASE_ITEMS.PURCHASENO
      ) 
      LEFT OUTER JOIN RP_VIEW_ANV_LOGIN_NAME RP_VIEW_ANV_LOGIN_NAME_MOT     
 ON PURCHASE_HEAD.MOT = RP_VIEW_ANV_LOGIN_NAME_MOT.KEY1
    ) 
    LEFT OUTER JOIN RP_VIEW_ANV_LOGIN_NAME RP_VIEW_ANV_LOGIN_NAME_BEST 
ON PURCHASE_HEAD.BEST = RP_VIEW_ANV_LOGIN_NAME_BEST.KEY1
   ) 
    LEFT OUTER JOIN ANV ANV ON PURCHASE_HEAD.SIGN = ANV.LOGIN } 
     WHERE 
      PURCHASE_HEAD.PURCHASENO = 210035 
      ORDER BY 
       PURCHASE_HEAD.PURCHASENO, 
       PURCHASE_ITEMS.PURCHASEROW

1 个答案:

答案 0 :(得分:0)

试试这个:

(isNull(PURCHASE_ITEMS.ANTAL,0) * isNull(PURCHASE_ITEMS.ENHETSPRIS,0)) AS TOTALSUM