I am trying to figure out I can change the data on the fly.
This is my current query:
SELECT [EmployeeTC_No] AS "Employee TC#"
,[pye_nlast] AS "Name Last"
,[pye_nfirst] AS "Name First"
,[Dept] AS "Department"
,[pye_status] AS "Active"
,[HireDate] AS "Hire Date"
,[SeparationDate] AS "Separation Date"
FROM [testing].[dbo].[testing]
In the column of pye_status the data comes in as "A" or "T" and I want it to be "1" or "0".
I have tried to add a case statement trying to do some kind of switch but nothing appears to even get me close.
CASE/WHEN should do the trick:
,CASE WHEN [pye_status] = 'A' THEN 1
WHEN [pye_status] = 'T' THEN 0
ELSE NULL END AS "Active"
Or a simple case/when will work too:
, CASE [pye_status]
WHEN 'A' THEN 1
WHEN 'T' THEN 0
ELSE NULL END AS "Active"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.