【问题标题】:RedShift <= integer invalid operator in case statement案例语句中的 RedShift <= 整数无效运算符
【发布时间】:2019-04-27 01:11:54
【问题描述】:

我有:

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;

但我收到错误

谢谢,

【问题讨论】:

    标签: amazon-redshift


    【解决方案1】:

    修复它:

    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;
    

    【讨论】:

      猜你喜欢
      • 2011-04-04
      • 1970-01-01
      • 1970-01-01
      • 2011-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-17
      • 1970-01-01
      相关资源
      最近更新 更多