如果道布在所显示的日期内,我想返回引号中的值,但数据返回时只显示其他值。有什么想法吗?
CASE
WHEN [Date of Birth] between 01/01/1945 and 31/12/1964 then 'Baby Boomer'
WHEN [Date of Birth] between 01/01/1965 and 31/12/1981 then 'Gen X'
WHEN [Date of Birth] between 01/01/1982 and 31/12/1994 then 'Millenial / Gen Y'
WHEN [Date of Birth] between 01/01/1995 and 31/12/2010 then 'Gen Z'
WHEN [Date of Birth] =>01/01/2011 then 'Gen Alpha'
ELSE 'Other TBC'
END发布于 2022-07-07 15:29:26
日期应该是引号,对吧?如果这是TSQL:
另外,你应该把'31/12/1964‘改为'12/31/1964’,它应该是一个月接着一个月,然后是一年。
这样做是可行的:
CASE
WHEN [Date of Birth] between '01/01/1945' and '12/31/1964' then 'Baby Boomer'
WHEN [Date of Birth] between '01/01/1965' and '12/31/1981' then 'Gen X'
WHEN [Date of Birth] between '01/01/1982' and '12/31/1994' then 'Millenial / Gen Y'
WHEN [Date of Birth] between '01/01/1995' and '12/31/2010' then 'Gen Z'
WHEN [Date of Birth] >= '01/01/2011' then 'Gen Alpha' -- changed => to >=
ELSE 'Other TBC'
ENDhttps://stackoverflow.com/questions/72900458
复制相似问题