解读下这段sqlselect region_code,count(*) from ( select substr(region_code,0,6) region_code,receive_number from tysl.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_gy.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_zy.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_lps.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_ga.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_as.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_bjs.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_trs.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_qn.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_qxn.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' union all select substr(region_code,0,6) region_code,receive_number from tysl_qdn.accept_business_index where receive_time between to_date('2023/5/1','yyyy/mm/dd') and to_date('2023/6/1','yyyy/mm/dd') and state !='90' )group by region_code order by region_code
时间: 2024-02-05 17:04:43 浏览: 122
这段 SQL 查询语句的作用是统计从 2023 年 5 月 1 日到 2023 年 6 月 1 日之间,多个表中的业务接收数量,并按照地区代码进行分组并排序。具体的解读如下:
首先,使用 union all 连接多个表中符合条件的数据,这些表分别是 tysl.accept_business_index、tysl_gy.accept_business_index、tysl_zy.accept_business_index、tysl_lps.accept_business_index、tysl_ga.accept_business_index、tysl_as.accept_business_index、tysl_bjs.accept_business_index、tysl_trs.accept_business_index、tysl_qn.accept_business_index、tysl_qxn.accept_business_index、tysl_qdn.accept_business_index。
接着,使用 substr 函数截取 region_code 字段的前六位,然后按照截取后的结果进行分组。
然后,使用 count 函数统计每个地区代码下的业务接收数量。
最后,通过 order by 子句按照地区代码进行排序,得到最终结果。
阅读全文