Hy,我有多个值,我需要一个检查列表,
例如:
1,2,4,
3,4,
应该是:
day1 day2 day3 day4
_1____1____0____1
_0____0____1____1
一种方法是
CAST(CASE WHEN PATINDEX('1,', [day]) > 0 THEN 1 ELSE 0 END AS BIT) as [day1],
CAST(CASE WHEN PATINDEX('2,', [day]) > 0 THEN 1 ELSE 0 END AS BIT) as [day2],
CAST(CASE WHEN PATINDEX('3,', [day]) > 0 THEN 1 ELSE 0 END AS BIT) as [day3],
CAST(CASE WHEN PATINDEX('4,', [day]) > 0 THEN 1 ELSE 0 END AS BIT) as [day4]
请帮助我更好的方法,因为我有多个列
谢谢