SQL 语句怎么写 一对多 mapping (如何写 sql 语句,关于 case when 或者 oracle 的 decode)
2014-02-12 23:53:12 +08:00
junjies
用例子来说吧:
比如case when, 我可以通过判断IOG来得到region为 1或7或3
REGION = CASE WHEN IOG IN (1,2,14,37,72,101) THEN '1' WHEN IOG IN (11,22,48,77) THEN '7' WHEN IOG IN (7,13,18,24,39) THEN '3' ELSE NULL END
有什么办法可以让它反过来, 比如 (当然下面这么写语法是错的) IOG in case when REGION = 1 THEN (1,2,14,37,72,101) WHEN REGION = 7 THEN (11,22,48,77) WHEN REGION = 3 THEN (7,13,18,24,39) ELSE NULL END