我的表格如下:
id customer_code comments
-----------------------------------
1 Dilbert true
2 Dilbert false
3 Wally true
4 wally true
5 wally false
我需要结果如下:
id customer_code x1 x2
------------------------------
1 Dilbert ture
2 Dilbert false
3 wally ture
4 wally ture
5 wally false
答案 0 :(得分:0)
SELECT [id], [customer_code],
CASE [comments] WHEN 'TRUE' THEN 'TRUE' ELSE NULL END AS X1,
CASE [comments] WHEN 'FALSE' THEN 'FALSE' ELSE NULL END AS X2
FROM Table1;
<强> FIDDLE 强>