case 字段名 when 和 case when 有什么区别
1
Semoz 2019-06-10 11:47:06 +08:00
CASE type WHEN 1 THEN 'a' WHEN 2 THEN 'b' ELSE 'c' END
CASE WHEN type > 5 THEN 'd' WHEN type < 0 THEN 'e' ELSE 'f' END 你说啥区别? |
2
zxcjqyy OP SELECT (CASE
WHEN MOD(id,2) = 1 AND id = (SELECT COUNT(*) FROM seat) THEN id WHEN MOD(id,2) = 1 THEN id+1 ElSE id-1 END) AS id, student FROM seat ORDER BY id; select (case id when mod(id,2)=1 and id = (select count(*) from seat) then id when mod(id,2)=1 then id+1 else id-1 end)id, student from seat order by id 那这 2 个 sql 结果为什么会不一样 |