0
我有以下查询,需要从Oracle移植到MySQL。它在两者中都没有任何编译错误,但结果表是不同的。在Oracle中,每个计数列下都有个别计数。但在MySQL中,无论计数应该在哪里,它们都会在a5以下。像这样:从Oracle到MySQL的CASE语句
在Oracle:
但在MySQL:
select x1.alert_level, count(x1.a1), count(x1.a2), count(x1.a3),
count(x1.a4), count(x1.a5) from
(select
table_name.column_name alias,
case when (now() - column_name) <= 7 then 1 end as a1,
case when (now() - column_name) between 7 and 30 then 1 end as a2,
case when (now() - column_name) between 30 and 60 then 1 end as a3,
case when (now() - column_name) between 60 and 90 then 1 end as a4,
case when (now() - column_name) >= 90 then 1 end as a5
FROM tables
WHERE filter_conditions) x1 GROUP BY x1.alias;
我如何可以调和的分歧,使MySQL的输出看起来像甲骨文输出?感谢您的帮助!
“condition”是一个列还是一个更复杂的表达式? – 2013-02-28 23:05:16
这是一个简单的条件或表达。除非指定,否则不包含任何列:) – CodingInCircles 2013-02-28 23:06:07
然后发表该表达式。这个问题可能在那里。 – 2013-02-28 23:06:40