SELECT bc.id as businessCompanyId, bc.company_name as businessCompanyName, any_value(su.`user_name`) as businessUser, bcff.type as fileType, fcl.clean_type as fileType, -- CASE sex WHEN ‘1’ THEN ‘男’ WHEN ‘2’ THEN ‘女’ ELSE ‘其他’ END CASE fcl.clean_type when 0 then count(fcl.id) as goodsCodeErrorNum when 1 then count(fcl.id) as hospitalNameErrorNum when 2 then count(fcl.id) as orderTypeErrorNum END FROM business_company bc INNER JOIN business_company_flow_file bcff ON bcff.business_company_id = bc.id INNER JOIN business_flow_detail bfd ON bcff.id = bfd.flow_file_id INNER JOIN flow_clean_log fcl ON fcl.business_flow_detail_id = bfd.id LEFT JOIN sys_user su ON su.user_id = bc.user_id GROUP BY bc.id, bcff.type, fcl.clean_type
时间: 2024-02-14 22:35:17 浏览: 294
MySQL 分表优化试验代码
这是一条 SQL 查询语句,它的功能是从多个表中查询数据并进行聚合。具体来说,它查询了 business_company 表、business_company_flow_file 表、business_flow_detail 表、flow_clean_log 表和 sys_user 表,然后根据 business_company 的 id、business_company_flow_file 的 type 和 flow_clean_log 的 clean_type 进行分组,最后对每组数据进行统计计数。其中,any_value 函数用于返回一组值中的任意一个值,CASE 语句用于根据条件返回不同的值。
阅读全文