hive长句
Posted lybpy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hive长句相关的知识,希望对你有一定的参考价值。
"select 大区, 配送中心, nvl(洗衣机,‘_‘) 洗衣机, nvl(冰箱,‘_‘) 冰箱, nvl(电热水器,‘_‘) 电热水器, nvl(燃气热水器,‘_‘) 燃气热水器, nvl(燃气灶,‘_‘) 燃气灶, nvl(油烟机,‘_‘) 油烟机, nvl(空调,‘_‘) 空调, nvl(平板电视,‘_‘) 平板电视, nvl(消毒柜,‘_‘) 消毒柜, nvl(洗碗机,‘_‘) 洗碗机, nvl(家庭影院,‘_‘) 家庭影院, nvl(DVD电视盒子,‘_‘) DVD电视盒子, nvl(迷你音响,‘_‘) 迷你音响, nvl(酒柜,‘_‘) 酒柜, nvl(冷柜冰吧,‘_‘) 冷柜冰吧, nvl(微波炉,‘_‘) 微波炉, nvl(饮水机,‘_‘) 饮水机 from ( select ‘1‘ as paixu, ‘总计‘ as 大区 , ‘总计‘ as 配送中心 , concat(round((nvl(sum(case when item_third_cate_cd = ‘880‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘880‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 洗衣机, concat(round((nvl(sum(case when item_third_cate_cd = ‘878‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘878‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 冰箱, concat(round((nvl(sum(case when item_third_cate_cd = ‘13690‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13690‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 电热水器, concat(round((nvl(sum(case when item_third_cate_cd = ‘13691‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13691‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 燃气热水器, concat(round((nvl(sum(case when item_third_cate_cd = ‘13298‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13298‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 燃气灶, concat(round((nvl(sum(case when item_third_cate_cd = ‘1300‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1300‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 油烟机, concat(round((nvl(sum(case when item_third_cate_cd = ‘870‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘870‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 空调, concat(round((nvl(sum(case when item_third_cate_cd = ‘798‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘798‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 平板电视, concat(round((nvl(sum(case when item_third_cate_cd = ‘1301‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1301‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 消毒柜, concat(round((nvl(sum(case when item_third_cate_cd = ‘13117‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13117‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 洗碗机, concat(round((nvl(sum(case when item_third_cate_cd = ‘823‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘823‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 家庭影院, concat(round((nvl(sum(case when item_third_cate_cd = ‘965‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘965‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as DVD电视盒子, concat(round((nvl(sum(case when item_third_cate_cd = ‘1199‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1199‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 迷你音响, concat(round((nvl(sum(case when item_third_cate_cd = ‘12401‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘12401‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 酒柜, concat(round((nvl(sum(case when item_third_cate_cd = ‘12392‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘12392‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 冷柜冰吧, concat(round((nvl(sum(case when item_third_cate_cd = ‘758‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘758‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 微波炉, concat(round((nvl(sum(case when item_third_cate_cd = ‘750‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘750‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 饮水机 from ( SELECT dt , item_third_cate_cd, region_name , case when pei = ‘包头‘ then ‘呼和浩特‘ when pei = ‘南海‘then ‘广州‘ when pei = ‘佛山‘ then ‘广州‘ when pei = ‘深圳‘then ‘广州‘ when pei = ‘东莞‘ then ‘广州‘ when pei = ‘茂名‘ then ‘广州‘ when pei = ‘济宁‘ then ‘济南‘ when pei = ‘浦东‘ then ‘上海‘ when pei = ‘柳州‘ then ‘南宁‘ when pei = ‘衡阳‘ then ‘长沙‘ when pei = ‘洛阳‘ then ‘郑州‘ when pei = ‘固安‘ then ‘北京‘ else pei end pei, sum(xiao) xiao from ( SELECT item_sku_id , item_third_cate_cd , item_second_cate_name, item_third_cate_name , barndname_full , work_post_cd FROM gdm.gdm_m03_self_item_sku_da WHERE dt = sysdate( - 1) and item_third_cate_cd in(‘760‘, ‘740‘, ‘741‘, ‘757‘, ‘806‘, ‘758‘, ‘1278‘, ‘1279‘, ‘881‘, ‘1289‘, ‘898‘, ‘759‘, ‘1287‘, ‘12397‘, ‘882‘, ‘9249‘, ‘748‘, ‘756‘, ‘750‘, ‘13116‘, ‘12400‘, ‘902‘, ‘742‘, ‘12394‘, ‘899‘, ‘1301‘, ‘762‘, ‘967‘, ‘963‘, ‘761‘, ‘801‘, ‘965‘, ‘14383‘, ‘795‘, ‘1199‘, ‘14381‘, ‘1283‘, ‘13702‘, ‘14382‘, ‘12398‘, ‘12395‘, ‘14380‘, ‘823‘, ‘13117‘,‘880‘, ‘878‘, ‘13690‘, ‘13691‘, ‘13298‘, ‘1300‘, ‘870‘, ‘798‘, ‘753‘, ‘755‘, ‘749‘, ‘745‘,‘12392‘,‘12401‘) ) a join ( select dept_id , dept_id_1 , dept_name_1, dept_id_2 , dept_name_2, dept_id_3 , dept_name_3, dept_id_4 , dept_name_4 from dim.dim_cmo_dept where dept_id_1 in(‘35‘) ) b on a.work_post_cd = b.dept_id JOIN ( SELECT dt , item_sku_id , delv_center_num, sum(cw_quantity) xiao FROM app.v_app_cmo_cw_ord_det_sum_jd WHERE ( ( dt = month_add(sysdate( - 1), - 12) ) OR ( dt = sysdate( - 1) ) ) and substr(ord_flag, 40, 1) <> ‘1‘ and sale_ord_type_cd <> ‘88‘ group BY dt , item_sku_id, delv_center_num ) c on a.item_sku_id = c.item_sku_id join ( select delv_center_num , regexp_replace(dim_delv_center_name, ‘配送中心‘, ‘‘) pei, region_name from dim.dim_delv_center ) d on c.delv_center_num = d.delv_center_num group BY dt , item_third_cate_cd, region_name , case when pei = ‘包头‘ then ‘呼和浩特‘ when pei = ‘南海‘then ‘广州‘ when pei = ‘佛山‘ then ‘广州‘ when pei = ‘深圳‘then ‘广州‘ when pei = ‘东莞‘ then ‘广州‘ when pei = ‘茂名‘ then ‘广州‘ when pei = ‘济宁‘ then ‘济南‘ when pei = ‘浦东‘ then ‘上海‘ when pei = ‘柳州‘ then ‘南宁‘ when pei = ‘衡阳‘ then ‘长沙‘ when pei = ‘洛阳‘ then ‘郑州‘ when pei = ‘固安‘ then ‘北京‘ else pei end )e union select case when region_name=‘华北‘ then ‘2‘ when region_name=‘华东‘ then ‘3‘ when region_name=‘华中‘ then ‘4‘ when region_name=‘华南‘ then ‘5‘ when region_name=‘东北‘ then ‘6‘ when region_name=‘西南‘ then ‘7‘ when region_name=‘西北‘ then ‘8‘ end paixu, region_name 大区 , pei 配送中心 , concat(round((nvl(sum(case when item_third_cate_cd = ‘880‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘880‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 洗衣机, concat(round((nvl(sum(case when item_third_cate_cd = ‘878‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘878‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 冰箱, concat(round((nvl(sum(case when item_third_cate_cd = ‘13690‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13690‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 电热水器, concat(round((nvl(sum(case when item_third_cate_cd = ‘13691‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13691‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 燃气热水器, concat(round((nvl(sum(case when item_third_cate_cd = ‘13298‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13298‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 燃气灶, concat(round((nvl(sum(case when item_third_cate_cd = ‘1300‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1300‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 油烟机, concat(round((nvl(sum(case when item_third_cate_cd = ‘870‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘870‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 空调, concat(round((nvl(sum(case when item_third_cate_cd = ‘798‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘798‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 平板电视, concat(round((nvl(sum(case when item_third_cate_cd = ‘1301‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1301‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 消毒柜, concat(round((nvl(sum(case when item_third_cate_cd = ‘13117‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13117‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 洗碗机, concat(round((nvl(sum(case when item_third_cate_cd = ‘823‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘823‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 家庭影院, concat(round((nvl(sum(case when item_third_cate_cd = ‘965‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘965‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as DVD电视盒子, concat(round((nvl(sum(case when item_third_cate_cd = ‘1199‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1199‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 迷你音响, concat(round((nvl(sum(case when item_third_cate_cd = ‘12401‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘12401‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 酒柜, concat(round((nvl(sum(case when item_third_cate_cd = ‘12392‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘12392‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 冷柜冰吧, concat(round((nvl(sum(case when item_third_cate_cd = ‘758‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘758‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 微波炉, concat(round((nvl(sum(case when item_third_cate_cd = ‘750‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘750‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 饮水机 from ( SELECT dt , item_third_cate_cd, region_name , case when pei = ‘包头‘ then ‘呼和浩特‘ when pei = ‘南海‘then ‘广州‘ when pei = ‘佛山‘ then ‘广州‘ when pei = ‘深圳‘then ‘广州‘ when pei = ‘东莞‘ then ‘广州‘ when pei = ‘茂名‘ then ‘广州‘ when pei = ‘济宁‘ then ‘济南‘ when pei = ‘浦东‘ then ‘上海‘ when pei = ‘柳州‘ then ‘南宁‘ when pei = ‘衡阳‘ then ‘长沙‘ when pei = ‘洛阳‘ then ‘郑州‘ when pei = ‘固安‘ then ‘北京‘ else pei end pei, sum(xiao) xiao from ( SELECT item_sku_id , item_third_cate_cd , item_second_cate_name, item_third_cate_name , barndname_full , work_post_cd FROM gdm.gdm_m03_self_item_sku_da WHERE dt = sysdate( - 1) and item_third_cate_cd in(‘760‘, ‘740‘, ‘741‘, ‘757‘, ‘806‘, ‘758‘, ‘1278‘, ‘1279‘, ‘881‘, ‘1289‘, ‘898‘, ‘759‘, ‘1287‘, ‘12397‘, ‘882‘, ‘9249‘, ‘748‘, ‘756‘, ‘750‘, ‘13116‘, ‘12400‘, ‘902‘, ‘742‘, ‘12394‘, ‘899‘, ‘1301‘, ‘762‘, ‘967‘, ‘963‘, ‘761‘, ‘801‘, ‘965‘, ‘14383‘, ‘795‘, ‘1199‘, ‘14381‘, ‘1283‘, ‘13702‘, ‘14382‘, ‘12398‘, ‘12395‘, ‘14380‘, ‘823‘, ‘13117‘,‘880‘, ‘878‘, ‘13690‘, ‘13691‘, ‘13298‘, ‘1300‘, ‘870‘, ‘798‘, ‘753‘, ‘755‘, ‘749‘, ‘745‘,‘12392‘,‘12401‘) ) a join ( select dept_id , dept_id_1 , dept_name_1, dept_id_2 , dept_name_2, dept_id_3 , dept_name_3, dept_id_4 , dept_name_4 from dim.dim_cmo_dept where dept_id_1 in(‘35‘) ) b on a.work_post_cd = b.dept_id JOIN ( SELECT dt , item_sku_id , delv_center_num, sum(cw_quantity) xiao FROM app.v_app_cmo_cw_ord_det_sum_jd WHERE ( ( dt = month_add(sysdate( - 1), - 12) ) OR ( dt = sysdate( - 1) ) ) and substr(ord_flag, 40, 1) <> ‘1‘ and sale_ord_type_cd <> ‘88‘ group BY dt , item_sku_id, delv_center_num ) c on a.item_sku_id = c.item_sku_id join ( select delv_center_num , regexp_replace(dim_delv_center_name, ‘配送中心‘, ‘‘) pei, region_name from dim.dim_delv_center ) d on c.delv_center_num = d.delv_center_num group BY dt , item_third_cate_cd, region_name , case when pei = ‘包头‘ then ‘呼和浩特‘ when pei = ‘南海‘then ‘广州‘ when pei = ‘佛山‘ then ‘广州‘ when pei = ‘深圳‘then ‘广州‘ when pei = ‘东莞‘ then ‘广州‘ when pei = ‘茂名‘ then ‘广州‘ when pei = ‘济宁‘ then ‘济南‘ when pei = ‘浦东‘ then ‘上海‘ when pei = ‘柳州‘ then ‘南宁‘ when pei = ‘衡阳‘ then ‘长沙‘ when pei = ‘洛阳‘ then ‘郑州‘ when pei = ‘固安‘ then ‘北京‘ else pei end )e group by region_name , pei union select case when 大区=‘华北合计‘ then ‘2‘ when 大区=‘华东合计‘ then ‘3‘ when 大区=‘华中合计‘ then ‘4‘ when 大区=‘华南合计‘ then ‘5‘ when 大区=‘东北合计‘ then ‘6‘ when 大区=‘西南合计‘ then ‘7‘ when 大区=‘西北合计‘ then ‘8‘ end paixu, 大区, 配送中心 , 洗衣机, 冰箱, 电热水器, 燃气热水器, 燃气灶, 油烟机, 空调, 平板电视, 消毒柜, 洗碗机, 家庭影院, DVD电视盒子, 迷你音响, 酒柜, 冷柜冰吧, 微波炉, 饮水机 FROM ( SELECT case when region_name=‘东北‘ then ‘东北合计‘ when region_name=‘华东‘ then ‘华东合计‘ when region_name=‘华中‘ then ‘华中合计‘ when region_name=‘华北‘ then ‘华北合计‘ when region_name=‘华南‘ then ‘华南合计‘ when region_name=‘西北‘ then ‘西北合计‘ when region_name=‘西南‘ then ‘西南合计‘ end 大区, ‘总计‘ as 配送中心 , concat(round((nvl(sum(case when item_third_cate_cd = ‘880‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘880‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 洗衣机, concat(round((nvl(sum(case when item_third_cate_cd = ‘878‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘878‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 冰箱, concat(round((nvl(sum(case when item_third_cate_cd = ‘13690‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13690‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 电热水器, concat(round((nvl(sum(case when item_third_cate_cd = ‘13691‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13691‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 燃气热水器, concat(round((nvl(sum(case when item_third_cate_cd = ‘13298‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13298‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 燃气灶, concat(round((nvl(sum(case when item_third_cate_cd = ‘1300‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1300‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 油烟机, concat(round((nvl(sum(case when item_third_cate_cd = ‘870‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘870‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 空调, concat(round((nvl(sum(case when item_third_cate_cd = ‘798‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘798‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 平板电视, concat(round((nvl(sum(case when item_third_cate_cd = ‘1301‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1301‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 消毒柜, concat(round((nvl(sum(case when item_third_cate_cd = ‘13117‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘13117‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 洗碗机, concat(round((nvl(sum(case when item_third_cate_cd = ‘823‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘823‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 家庭影院, concat(round((nvl(sum(case when item_third_cate_cd = ‘965‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘965‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as DVD电视盒子, concat(round((nvl(sum(case when item_third_cate_cd = ‘1199‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘1199‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 迷你音响, concat(round((nvl(sum(case when item_third_cate_cd = ‘12401‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘12401‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 酒柜, concat(round((nvl(sum(case when item_third_cate_cd = ‘12392‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘12392‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 冷柜冰吧, concat(round((nvl(sum(case when item_third_cate_cd = ‘758‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘758‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 微波炉, concat(round((nvl(sum(case when item_third_cate_cd = ‘750‘ and dt = sysdate( - 1) then xiao end),0)/ nvl(sum(case when item_third_cate_cd = ‘750‘ and dt = month_add(sysdate( - 1), - 12) then xiao end),0))-1,4)*100,‘%‘) as 饮水机 from ( SELECT dt , item_third_cate_cd, region_name , case when pei = ‘包头‘ then ‘呼和浩特‘ when pei = ‘南海‘then ‘广州‘ when pei = ‘佛山‘ then ‘广州‘ when pei = ‘深圳‘then ‘广州‘ when pei = ‘东莞‘ then ‘广州‘ when pei = ‘茂名‘ then ‘广州‘ when pei = ‘济宁‘ then ‘济南‘ when pei = ‘浦东‘ then ‘上海‘ when pei = ‘柳州‘ then ‘南宁‘ when pei = ‘衡阳‘ then ‘长沙‘ when pei = ‘洛阳‘ then ‘郑州‘ when pei = ‘固安‘ then ‘北京‘ else pei end pei, sum(xiao) xiao from ( SELECT item_sku_id , item_third_cate_cd , item_second_cate_name, item_third_cate_name , barndname_full , work_post_cd FROM gdm.gdm_m03_self_item_sku_da WHERE dt = sysdate( - 1) and item_third_cate_cd in(‘760‘, ‘740‘, ‘741‘, ‘757‘, ‘806‘, ‘758‘, ‘1278‘, ‘1279‘, ‘881‘, ‘1289‘, ‘898‘, ‘759‘, ‘1287‘, ‘12397‘, ‘882‘, ‘9249‘, ‘748‘, ‘756‘, ‘750‘, ‘13116‘, ‘12400‘, ‘902‘, ‘742‘, ‘12394‘, ‘899‘, ‘1301‘, ‘762‘, ‘967‘, ‘963‘, ‘761‘, ‘801‘, ‘965‘, ‘14383‘, ‘795‘, ‘1199‘, ‘14381‘, ‘1283‘, ‘13702‘, ‘14382‘, ‘12398‘, ‘12395‘, ‘14380‘, ‘823‘, ‘13117‘,‘880‘, ‘878‘, ‘13690‘, ‘13691‘, ‘13298‘, ‘1300‘, ‘870‘, ‘798‘, ‘753‘, ‘755‘, ‘749‘, ‘745‘,‘12392‘,‘12401‘) ) a join ( select dept_id , dept_id_1 , dept_name_1, dept_id_2 , dept_name_2, dept_id_3 , dept_name_3, dept_id_4 , dept_name_4 from dim.dim_cmo_dept where dept_id_1 in(‘35‘) ) b on a.work_post_cd = b.dept_id JOIN ( SELECT dt , item_sku_id , delv_center_num, sum(cw_quantity) xiao FROM app.v_app_cmo_cw_ord_det_sum_jd WHERE ( ( dt = month_add(sysdate( - 1), - 12) ) OR ( dt = sysdate( - 1) ) ) and substr(ord_flag, 40, 1) <> ‘1‘ and sale_ord_type_cd <> ‘88‘ group BY dt , item_sku_id, delv_center_num ) c on a.item_sku_id = c.item_sku_id join ( select delv_center_num , regexp_replace(dim_delv_center_name, ‘配送中心‘, ‘‘) pei, region_name from dim.dim_delv_center ) d on c.delv_center_num = d.delv_center_num group BY dt , item_third_cate_cd, region_name , case when pei = ‘包头‘ then ‘呼和浩特‘ when pei = ‘南海‘then ‘广州‘ when pei = ‘佛山‘ then ‘广州‘ when pei = ‘深圳‘then ‘广州‘ when pei = ‘东莞‘ then ‘广州‘ when pei = ‘茂名‘ then ‘广州‘ when pei = ‘济宁‘ then ‘济南‘ when pei = ‘浦东‘ then ‘上海‘ when pei = ‘柳州‘ then ‘南宁‘ when pei = ‘衡阳‘ then ‘长沙‘ when pei = ‘洛阳‘ then ‘郑州‘ when pei = ‘固安‘ then ‘北京‘ else pei end )e group by case when region_name=‘东北‘ then ‘东北合计‘ when region_name=‘华东‘ then ‘华东合计‘ when region_name=‘华中‘ then ‘华中合计‘ when region_name=‘华北‘ then ‘华北合计‘ when region_name=‘华南‘ then ‘华南合计‘ when region_name=‘西北‘ then ‘西北合计‘ when region_name=‘西南‘ then ‘西南合计‘ end )f )g WHERE 配送中心 not in (‘台州‘)"
以上是关于hive长句的主要内容,如果未能解决你的问题,请参考以下文章