I am trying to place a column next to CREATEDATBRANCH
that shows a name instead of a number. How can I do that?
This is my SQL query so far:
SELECT [PARENTACCOUNT]
,[ID]
,[TYPE]
,[ORIGINALDATE]
,[OPENDATE]
,[CHARGEOFFDATE]
,[CLOSEDATE]
,[PURPOSECODE]
,BALANCE AS 'Current Balance'
,[ORIGINALBALANCE]
,[CHARGEOFFTYPE]
,[CHARGEOFFAMOUNT]
,[DESCRIPTION]
,[MATURITYDATE]
,[BRANCH]
,[CREATEDBYUSER]
,[CREATEDATBRANCH]
FROM
[dbo].[LOAN]
WHERE
OPENDATE BETWEEN '2023-09-01' AND '2023-09-30'
AND CLOSEDATE IS NULL;
I tried to use this code but it does not include it in my query, instead it creates it as another result.
SELECT
CREATEDATBRANCH,
CASE
WHEN CREATEDATBRANCH = 0 THEN 'Special'
ELSE CAST(LOAN.CREATEDATBRANCH AS varchar(4))
END AS 'Location'
FROM
LOAN;
1条答案
按热度按时间6ljaweal1#
Take just the
CASE
expression from the second query and include it at the end of theSELECT
list in the first query.But really, I'd leave this adjustment for client code or the reporting tool.