SELECT t1.PeopleName as 姓名,t1.PeopleSex as 性别,
t1.PeopleSalary as 工资 ,t1.PeoplePhone as 电话,
t1.PeopleBirth as 生日,
case
when year(t1.PeopleBirth) % 12 = 4 then '鼠'
when year(t1.PeopleBirth) % 12 = 5 then '牛'
when year(t1.PeopleBirth) % 12 = 6 then '虎'
when year(t1.PeopleBirth) % 12 = 7 then '兔'
when year(t1.PeopleBirth) % 12 = 8 then '龙'
when year(t1.PeopleBirth) % 12 = 9 then '蛇'
when year(t1.PeopleBirth) % 12 = 10 then '马'
when year(t1.PeopleBirth) % 12 = 11 then '羊'
when year(t1.PeopleBirth) % 12 = 0 then '猴'
when year(t1.PeopleBirth) % 12 = 1 then '鸡'
when year(t1.PeopleBirth) % 12 = 2 then '狗'
when year(t1.PeopleBirth) % 12 = 3 then '猪'
ELSE ''
end 生肖
from People t1
T-SQL case when的使用
最新推荐文章于 2023-04-27 17:16:36 发布