我有一个SQL表,它的单元格如下所示:
室外游泳池、保安、水箱
我需要把手机转换成这样:
我不知道该怎么做。我不想让你为我这么做。但请给我一些建议。
请告诉我如何解析该列,生成新列并填充这些列。谢谢。
发布于 2016-10-11 12:22:10
使用like
select (case when col like '%outdoor pool%' then 1 else 0 end) as has_outdoorpool,
(case when col like '%indoor pool%' then 1 else 0 end) as has_indoorpool,
(case when col like '%security%' then 1 else 0 end) as has_security,
(case when col like '%water tank%' then 1 else 0 end) as has_watertank发布于 2016-10-11 12:25:49
使用PATINDEX可能也很有用,https://msdn.microsoft.com/en-us/library/ms188395.aspx
https://stackoverflow.com/questions/39977125
复制相似问题