SQL中的强制转换功能

时间:2020-08-27 16:00:59

标签: sql

我试图根据sql中列的状态打印报告,如果它像'P',如果列值是其他值,则应该返回一些文本,如果应该从特定列返回值,则应该返回

SELECT a.payment_id, a.contract_code, a.payment_amount,
       a.gst_amount, a.total, a.payment_date,
       a.paid_amount, a.initiated_date, UPPER(name) AS name,
       a.ccy, UPPER(a.remarks) AS remarks, a.vendor_inv_no AS invoiceNo,
       b.contract_amount AS freeText1,
       c.user_loginName AS freeText2,
       c.user_createdOn AS freeText3,
       CASE
         WHEN a.row_status = 'P' THEN
          a.modified_by = 'Yet To Be Authorised'
         ELSE
          a.modified_by
       END AS modified_by 
  FROM payment_master a
  LEFT JOIN tbl_dmssuppliers
    ON vendor_id = codeno
  JOIN contract_master b
    ON b.contract_id = a.contract_code
  JOIN tbl_dmsusers c
    ON c.user_id = a.created_by
  JOIN budget_master d
    ON d.budget_id = a.budget_code

我无法弄清楚哪里出了错

0 个答案:

没有答案