查寻
SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
select \* ,
case
when year(PeopleBirth) % 12 = 4 then '鼠'
when year(PeopleBirth) % 12 = 5 then '牛'
when year(PeopleBirth) % 12 = 6 then '虎'
when year(PeopleBirth) % 12 = 7 then '兔'
when year(PeopleBirth) % 12 = 8 then '龙'
when year(PeopleBirth) % 12 = 9 then '蛇'
when year(PeopleBirth) % 12 = 10 then '马'
when year(PeopleBirth) % 12 = 11 then '羊'
when year(PeopleBirth) % 12 = 0 then '猴'
when year(PeopleBirth) % 12 = 1 then '鸡'
when year(PeopleBirth) % 12 = 2 then '狗'
when year(PeopleBirth) % 12 = 3 then '猪'
简化版
SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
select \*,
case year(PeopleBirth) % 12
when 4 then '鼠'
when 4 then '牛'
when 4 then '虎'
when 4 then '兔'
when 4 then '龙'
when 4 then '蛇'
when 4 then '马'
when 4 then '羊'
when 4 then '猴'
when 4 then '鸡'
when 4 then '狗'
when 4 then '猪'