我试图弄清楚我可以随时更改数据。
这是我当前的查询:
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]
在pye_status列中,数据以“ A”或“ T”形式输入,我希望它是“ 1”或“ 0”。
我试图添加一个case语句以尝试进行某种切换,但似乎什么也没有使我关闭。
答案 0 :(得分:2)
案例/何时应该完成:
,CASE WHEN [pye_status] = 'A' THEN 1
WHEN [pye_status] = 'T' THEN 0
ELSE NULL END AS "Active"
或者一个简单的案例/什么时候也可以工作:
, CASE [pye_status]
WHEN 'A' THEN 1
WHEN 'T' THEN 0
ELSE NULL END AS "Active"
答案 1 :(得分:2)