为什么查询全国数据的时候没问题?查询其中一个省份的数据就报错?

image.png

image.png

FineReport 帆软用户fsQZFgE6mk 发布于 2024-7-12 16:47 (编辑于 2024-7-12 16:47)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
用户k6280494Lv6专家互助
发布于2024-7-12 16:48

发一下sql

  • 帆软用户fsQZFgE6mk 帆软用户fsQZFgE6mk(提问者) select '' as sdt --,'' as time_period -- ,b.manage_dist_id,b.manage_dist_name ,b.manage_dist_id,b.manage_dist_name,b.prov_id_ud,b.prov_name_ud -- ,b.manage_dist_id,b.manage_dist_name,b.prov_id_ud,b.prov_name_ud,b.city_id,b.city_name -- ,b.manage_dist_id,b.manage_dist_name,b.prov_id_ud,b.prov_name_ud,b.region_id_ud,b.Region_Name_ud -- ,b.manage_dist_id,b.manage_dist_name,b.prov_id_ud,b.prov_name_ud,b.region_id_ud,b.Region_Name_ud,b.shop_id,b.shop_name ,'' as goods_id1 ,'' as goods_name1 ,'汇总' as channel_dim_id ,'汇总' as channel_dim_desc /*销售数量*/ ,sum(case when (a.sdt BETWEEN '20240101' and '20240630') then sales_qty else 0 end) as sales_qty ,sum(case when (a.sdt BETWEEN '20230101' and '20230630') then sales_qty else 0 end) as sales_qty_y /*销售额*/ ,sum(case when (a.sdt BETWEEN '20240101' and '20240630') then restore_sales_amt else 0 end) as sales_amt ,sum(case when (a.sdt BETWEEN '20230101' and '20230630') then restore_sales_amt else 0 end) as sales_amt_y /*毛利额*/ ,sum(case when (a.sdt BETWEEN '20240101' and '20240630') then restore_gm_amt else 0 end) as gm_amt ,sum(case when (a.sdt BETWEEN '20230101' and '20230630') then restore_gm_amt else 0 end) as gm_amt_y /*客流*/ ,sum(case when (a.sdt BETWEEN '20240101' and '20240630') then custflow - ret_custflow else 0 end) as custflow ,sum(case when (a.sdt BETWEEN '20230101' and '20230630') then custflow - ret_custflow else 0 end) as custflow_y from dws.dws_sale_tp_category_sales_1d a inner join dim.dim_shop b on a.shop_id = b.shop_id and b.shop_sts='0000' inner join (select sales_channel_id as channel_id ,sales_channel_name channel_desc ,is_online ,case when is_online='1' then '线上' else '线下' end as online_name from dim.dim_channel ) as c on a.sales_channel_id=c.channel_id where ((a.sdt BETWEEN '20240101' and '20240630') or (a.sdt BETWEEN '20230101' and '20230630') ) -- and time_period <>'99' -- 剔除时段99的汇总数据 and stat_flag = '1' and a.shop_id in ('9200','9212','9238','9262','9301','9355','95G0', '95HG','95HS', '9744','9745','9248','9414','9210','9259','9302','9321','9356','95A9','9605','9608' ,'9609','9249','9405','90B4','90T0','9211','9323','9415','9552','9584','9746' ,'9441','9652','9881') -- and a.sales_channel_id in ('10','11','12','20','39','40','45','X1','Y5','Y6','Y7','Z1','30','31','32','33','34','36','37','38','41','42','43','44','46','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80') --and time_period BETWEEN '00' and '23' and is_yoy='Y' group by sdt ,b.manage_dist_id,b.manage_dist_name,b.prov_id_ud,b.prov_name_ud ,channel_dim_id ,channel_dim_desc ,goods_id1 ,goods_name1 order by sdt -- ,b.manage_dist_id,b.manage_dist_name ,b.manage_dist_id,b.manage_dist_name,b.prov_id_ud,b.prov_name_ud ,goods_id1 ,channel_dim_id ,channel_dim_desc limit 10000
    2024-07-12 17:37 
  • 帆软用户fsQZFgE6mk 帆软用户fsQZFgE6mk(提问者) 这个是错误代码
    2024-07-12 17:38 
最佳回答
0
小菜鸡222Lv4见习互助
发布于2024-7-12 16:52

通常这种情况下  都是全国的值 类型 跟 省份的值类型不一致。另外还是看你 SQL  全国 跟 省份 这两段逻辑设置的参数是不是一样   也可能是省份的参数写错了。这种是细节问题  得慢慢排查

  • 帆软用户fsQZFgE6mk 帆软用户fsQZFgE6mk(提问者) 但是我选择其他省份的时候是可以查询的出来的
    2024-07-12 17:40 
  • 小菜鸡222 小菜鸡222 回复 帆软用户fsQZFgE6mk(提问者) 如果 省份的语句 是同一段的情况下。切换别的省份没有报错,其中一两个出现报错,那就是 值的问题。你把值查询出来 再复制出来 看下 是不是存在空格。或者特殊符号。如果是系统取数的还好说 如果是人工填报的 或者系统取数源 也是人工填报的 是有小概率 发生这种乌龙的。
    2024-07-13 12:38 
  • 3关注人数
  • 131浏览人数
  • 最后回答于:2024-7-12 16:52
    请选择关闭问题的原因
    确定 取消
    返回顶部