I am trying to print a report based on the status of a column from sql if it is like 'P' it should be return some text if the column value is something else if should return a specific column
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) NAME,a.CCY,UPPER(a.REMARKS) 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
FROM PAYMENT_MASTER a
LEFT OUTER 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
a.TOTAL, a.PAYMENT_DATE,a.Paid_Amount,a.INITIATED_DATE,upper(NAME) NAME,a.CCY,UPPER(a.REMARKS) 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
FROM PAYMENT_MASTER a
LEFT OUTER 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
i am unable to figure where i went wrong kindly guide
Navaneeth KrishnanPosted Aug 27, 2020, 8:33 PM
Sumit KharchePosted Aug 27, 2020, 12:11 PM
https://www.guru99.com/sql-server-case.html
https://stackoverflow.com/questions/18834821/case-statement-in-select-query-in-sql
https://www.sqlshack.com/querying-data-using-the-sql-case-statement/