我有:
select
month,
year,
-- package 5 counts by sliding screening price
case
when total_count_package_5 <= 75 then SUM(total_count_package_5) end as total_count_package_5_15,
case
when total_count_package_5 >= 76 and <= 150 then SUM(total_count_package_5) end as total_count_package_5_13,
case
when total_count_package_5 >= 151 and <= 600 then SUM(total_count_package_5) end as total_count_package_5_12,
case
when total_count_package_5 >= 601 and <= 800 then SUM(total_count_package_5) end as total_count_package_5_10,
case
when total_count_package_5 >= 801 then SUM(total_count_package_5) end as total_count_package_5_8,
from screening_packages_5_6_count_2018
group by year, month, total_count_package_5, total_count_package_6
order by month, year desc;
但是我得到的错误是<=整数不存在。我在redshift手册上将其视为可用的运算符,但遇到错误。我还能在这里使用什么?
谢谢
答案 0 :(得分:0)
已解决:
select
month,
year,
-- package 5 counts by sliding screening price
case
when (total_count_package_5 <= 75) then SUM(total_count_package_5) end as total_count_package_5_15,
case
when (total_count_package_5 >= 76 and total_count_package_5<= 150) then SUM(total_count_package_5) end as total_count_package_5_13,
case
when (total_count_package_5 >= 151 and total_count_package_5<= 600) then SUM(total_count_package_5) end as total_count_package_5_12,
case
when (total_count_package_5 >= 601 and total_count_package_5<= 800) then SUM(total_count_package_5) end as total_count_package_5_10,
case
when (total_count_package_5 >= 801) then SUM(total_count_package_5) end as total_count_package_5_8,
-- package 6 counts by sliding screening price
case
when (total_count_package_6 <= 75) then sum(total_count_package_6) end as total_count_package_6_20,
case
when (total_count_package_6 >= 76 and total_count_package_5<= 150) then sum(total_count_package_6) end as total_count_package_6_18,
case
when (total_count_package_6 >= 151 and total_count_package_5<= 600) then sum(total_count_package_6) end as total_count_package_6_17,
case
when (total_count_package_6 >= 601 and total_count_package_5<= 800) then sum(total_count_package_6) end as total_count_package_6_15,
case
when (total_count_package_6 >= 801) then sum(total_count_package_6) end as total_count_package_6_13
from screening_packages_5_6_count_2018
group by year,month
, total_count_package_5, total_count_package_6
order by month desc;