在我的用例中,我需要做这样的事情,
INSERT INTO TABLE test
select
count(*) where recordedValue < 0,
count(*) where recordedValue > 0 and recordedValue < 10,
count(*) where recordedValue > 10 and recordedValue < 20
from sample
可以这样做吗?
答案 0 :(得分:2)
INSERT INTO TABLE test
select count(col1), count(col2), count(col3) From (
select
CASE WHEN recordedValue < 0 THEN recordedValue END as col1,
CASE WHEN recordedValue > 0 AND recordedValue < 10 THEN recordedValue END as col2,
CASE WHEN recordedValue > 10 AND recordedValue < 20 THEN recordedValue END as col3
from sample ) a;
首先检查select语句;