[
  {
    "question": "查询2023年4月1日各服务区的总营收金额，并按金额从高到低排序。",
    "sql": "SELECT service_name AS 服务区名称, SUM(pay_sum) AS 日收入总额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL GROUP BY service_name ORDER BY 日收入总额 DESC;"
  },
  {
    "question": "查询2023年4月1日各服务区的订单总数，并取前5名。",
    "sql": "SELECT service_name AS 服务区名称, SUM(order_sum) AS 订单总数 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL GROUP BY service_name ORDER BY 订单总数 DESC LIMIT 5;"
  },
  {
    "question": "查询2023年4月1日各支付方式的总金额及其占比。",
    "sql": "SELECT '微信' AS 支付方式, SUM(wx) AS 总金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '支付宝', SUM(zfb) FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '现金', SUM(rmb) FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '行吧', SUM(xs) FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL;"
  },
  {
    "question": "查询2023年4月1日宜春服务区的各支付方式订单数量。",
    "sql": "SELECT service_name AS 服务区名称, SUM(wx_order) AS 微信订单数, SUM(zf_order) AS 支付宝订单数, SUM(rmb_order) AS 现金订单数, SUM(xs_order) AS 行吧订单数 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND service_name = '宜春服务区' AND delete_ts IS NULL GROUP BY service_name;"
  },
  {
    "question": "查询2023年4月1日至2023年4月7日各服务区的平均日收入。",
    "sql": "SELECT service_name AS 服务区名称, AVG(pay_sum) AS 平均日收入 FROM bss_business_day_data WHERE oper_date BETWEEN '2023-04-01' AND '2023-04-07' AND delete_ts IS NULL GROUP BY service_name;"
  },
  {
    "question": "查询2023年4月1日宜春服务区各档口的营收排名。",
    "sql": "SELECT branch_name AS 档口名称, SUM(pay_sum) AS 营收金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND service_name = '宜春服务区' AND delete_ts IS NULL GROUP BY branch_name ORDER BY 营收金额 DESC;"
  },
  {
    "question": "查询2023年4月1日各服务区微信支付金额占总支付金额的比例。",
    "sql": "SELECT service_name AS 服务区名称, SUM(wx) / SUM(pay_sum) * 100 AS 微信占比百分比 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL GROUP BY service_name;"
  },
  {
    "question": "查询2023年4月1日订单总数超过200的服务区。",
    "sql": "SELECT service_name AS 服务区名称, SUM(order_sum) AS 订单总数 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL GROUP BY service_name HAVING SUM(order_sum) > 200;"
  },
  {
    "question": "查询2023年4月1日各服务区的现金支付金额和订单数明细。",
    "sql": "SELECT service_name AS 服务区名称, branch_name AS 档口名称, rmb AS 现金支付金额, rmb_order AS 现金订单数 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL;"
  },
  {
    "question": "查询2023年4月1日各服务区的支付方式分布，按微信支付金额从高到低排序。",
    "sql": "SELECT service_name AS 服务区名称, SUM(wx) AS 微信支付金额, SUM(zfb) AS 支付宝支付金额, SUM(rmb) AS 现金支付金额, SUM(xs) AS 行吧支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL GROUP BY service_name ORDER BY 微信支付金额 DESC;"
  },
  {
    "question": "统计每个服务区2023年4月1日当天的车流量，并按车流量降序排列。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bcc.customer_count) AS 当日车流量 FROM bss_car_day_count bcc JOIN bss_service_area bsa ON bcc.service_area_id = bsa.id WHERE bcc.count_date = '2023-04-01' AND bcc.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 当日车流量 DESC;"
  },
  {
    "question": "分析2023年4月1日至2023年4月7日各车辆类型的总占比情况。",
    "sql": "SELECT car_type AS 车辆类型, SUM(customer_count) AS 总车数, (SUM(customer_count) * 100.0 / (SELECT SUM(customer_count) FROM bss_car_day_count WHERE count_date BETWEEN '2023-04-01' AND '2023-04-07' AND delete_ts IS NULL)) AS 占比百分比 FROM bss_car_day_count WHERE count_date BETWEEN '2023-04-01' AND '2023-04-07' AND delete_ts IS NULL GROUP BY car_type;"
  },
  {
    "question": "找出2023年4月1日至2023年4月7日车流量最高的前5个服务区。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bcc.customer_count) AS 总车流量 FROM bss_car_day_count bcc JOIN bss_service_area bsa ON bcc.service_area_id = bsa.id WHERE bcc.count_date BETWEEN '2023-04-01' AND '2023-04-07' AND bcc.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 总车流量 DESC LIMIT 5;"
  },
  {
    "question": "统计2023年4月1日各车辆类型的车流量分布。",
    "sql": "SELECT car_type AS 车辆类型, customer_count AS 车流量 FROM bss_car_day_count WHERE count_date = '2023-04-01' AND delete_ts IS NULL;"
  },
  {
    "question": "分析过去7天每天的总车流量变化趋势。",
    "sql": "SELECT count_date AS 统计日期, SUM(customer_count) AS 总车流量 FROM bss_car_day_count WHERE count_date BETWEEN CURRENT_DATE - 7 AND CURRENT_DATE - 1 AND delete_ts IS NULL GROUP BY count_date ORDER BY count_date;"
  },
  {
    "question": "查询2023年4月1日车流量最少的3个服务区。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bcc.customer_count) AS 总车流量 FROM bss_car_day_count bcc JOIN bss_service_area bsa ON bcc.service_area_id = bsa.id WHERE bcc.count_date = '2023-04-01' AND bcc.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 总车流量 ASC LIMIT 3;"
  },
  {
    "question": "统计各车辆类型在不同服务区的平均每日车流量。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, car_type AS 车辆类型, AVG(customer_count) AS 平均日车流量 FROM bss_car_day_count bcc JOIN bss_service_area bsa ON bcc.service_area_id = bsa.id WHERE bcc.delete_ts IS NULL GROUP BY bsa.service_area_name, car_type ORDER BY 服务区名称, 车辆类型;"
  },
  {
    "question": "查找2023年4月1日车流量超过1000的车辆类型及对应服务区。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, car_type AS 车辆类型, customer_count AS 车流量 FROM bss_car_day_count bcc JOIN bss_service_area bsa ON bcc.service_area_id = bsa.id WHERE bcc.count_date = '2023-04-01' AND bcc.customer_count > 1000 AND bcc.delete_ts IS NULL;"
  },
  {
    "question": "比较2023年4月1日与2023年4月2日的车流量差异。",
    "sql": "SELECT count_date AS 统计日期, SUM(customer_count) AS 总车流量 FROM bss_car_day_count WHERE count_date IN ('2023-04-01', '2023-04-02') AND delete_ts IS NULL GROUP BY count_date;"
  },
  {
    "question": "统计2023年4月1日各服务区不同车辆类型的车流量明细。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, car_type AS 车辆类型, customer_count AS 车流量 FROM bss_car_day_count bcc JOIN bss_service_area bsa ON bcc.service_area_id = bsa.id WHERE bcc.count_date = '2023-04-01' AND bcc.delete_ts IS NULL ORDER BY 服务区名称, 车辆类型;"
  },
  {
    "question": "统计各分公司管理的服务区数量，并按数量降序排列。",
    "sql": "SELECT b.company_name AS 公司名称, COUNT(a.id) AS 服务区数量 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY b.company_name ORDER BY 服务区数量 DESC;"
  },
  {
    "question": "列出所有关闭状态的服务区及其所属分公司名称。",
    "sql": "SELECT a.service_area_name AS 服务区名称, b.company_name AS 所属分公司 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.service_state = '关闭' AND a.delete_ts IS NULL AND b.delete_ts IS NULL;"
  },
  {
    "question": "统计各分公司管理的开放与关闭服务区数量，并计算关闭比例。",
    "sql": "SELECT company_name AS 公司名称, SUM(CASE WHEN service_state = '开放' THEN 1 ELSE 0 END) AS 开放数量, SUM(CASE WHEN service_state = '关闭' THEN 1 ELSE 0 END) AS 关闭数量, ROUND(SUM(CASE WHEN service_state = '关闭' THEN 1 ELSE 0 END)::numeric / NULLIF(SUM(CASE WHEN service_state IN ('开放', '关闭') THEN 1 ELSE 0 END), 0), 4) AS 关闭比例 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY company_name;"
  },
  {
    "question": "查找最近一个月内新增的服务区及其所属公司名称。",
    "sql": "SELECT a.service_area_name AS 服务区名称, b.company_name AS 所属公司 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.create_ts >= CURRENT_DATE - INTERVAL '1 month' AND a.delete_ts IS NULL AND b.delete_ts IS NULL;"
  },
  {
    "question": "列出管理超过10个服务区的分公司名称及对应数量。",
    "sql": "SELECT b.company_name AS 公司名称, COUNT(a.id) AS 服务区数量 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY b.company_name HAVING COUNT(a.id) > 10;"
  },
  {
    "question": "列出所有服务区状态为上传数据的记录及其所属分公司名称。",
    "sql": "SELECT a.service_area_name AS 服务区名称, b.company_name AS 所属分公司 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.service_state = '上传数据' AND a.delete_ts IS NULL AND b.delete_ts IS NULL;"
  },
  {
    "question": "按服务区类型统计各分公司管理的服务区数量。",
    "sql": "SELECT b.company_name AS 公司名称, a.service_area_type AS 服务区类型, COUNT(a.id) AS 数量 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY b.company_name, a.service_area_type;"
  },
  {
    "question": "列出管理最少服务区的前5个分公司。",
    "sql": "SELECT b.company_name AS 公司名称, COUNT(a.id) AS 服务区数量 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY b.company_name ORDER BY 服务区数量 ASC LIMIT 5;"
  },
  {
    "question": "统计各分公司管理的开放、关闭及上传数据状态的服务区数量。",
    "sql": "SELECT b.company_name AS 公司名称, SUM(CASE WHEN a.service_state = '开放' THEN 1 ELSE 0 END) AS 开放数量, SUM(CASE WHEN a.service_state = '关闭' THEN 1 ELSE 0 END) AS 关闭数量, SUM(CASE WHEN a.service_state = '上传数据' THEN 1 ELSE 0 END) AS 上传数据数量 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY b.company_name;"
  },
  {
    "question": "列出每个分公司中最近更新的服务区记录。",
    "sql": "SELECT b.company_name AS 公司名称, a.service_area_name AS 服务区名称, a.update_ts AS 最后更新时间 FROM bss_service_area a INNER JOIN bss_company b ON a.company_id = b.id WHERE a.delete_ts IS NULL AND b.delete_ts IS NULL ORDER BY a.update_ts DESC LIMIT 10;"
  },
  {
    "question": "统计每条路线关联的服务区数量，并按数量降序排列。",
    "sql": "SELECT route_name AS 路线名称, COUNT(service_area_id) AS 关联服务区数量 FROM bss_section_route JOIN bss_section_route_area_link ON id = section_route_id WHERE delete_ts IS NULL GROUP BY route_name ORDER BY 关联服务区数量 DESC;"
  },
  {
    "question": "列出所有未关联任何路线的服务区名称及其编码。",
    "sql": "SELECT service_area_name AS 服务区名称, service_area_no AS 服务区编码 FROM bss_service_area WHERE id NOT IN (SELECT service_area_id FROM bss_section_route_area_link) AND delete_ts IS NULL;"
  },
  {
    "question": "查询每个路段包含的服务区数量，并展示路段名称和服务区数量。",
    "sql": "SELECT section_name AS 路段名称, COUNT(service_area_id) AS 服务区数量 FROM bss_section_route JOIN bss_section_route_area_link ON id = section_route_id WHERE delete_ts IS NULL GROUP BY section_name;"
  },
  {
    "question": "找出关联服务区数量最多的前5条路线。",
    "sql": "SELECT route_name AS 路线名称, COUNT(service_area_id) AS 服务区数量 FROM bss_section_route JOIN bss_section_route_area_link ON id = section_route_id WHERE delete_ts IS NULL GROUP BY route_name ORDER BY 服务区数量 DESC LIMIT 5;"
  },
  {
    "question": "查询2023年4月1日当天，每个服务区对应的微信支付总额，并按支付总额降序排序。",
    "sql": "SELECT service_name AS 服务区名称, SUM(wx) AS 微信支付总额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL GROUP BY service_name ORDER BY 微信支付总额 DESC;"
  },
  {
    "question": "统计2022年3月进入每个服务区的车辆总数，并按车辆总数降序排序。",
    "sql": "SELECT service_area_id AS 服务区ID, SUM(customer_count) AS 进入车辆总数 FROM bss_car_day_count WHERE count_date BETWEEN '2022-03-01' AND '2022-03-31' AND delete_ts IS NULL GROUP BY service_area_id ORDER BY 进入车辆总数 DESC;"
  },
  {
    "question": "查询每个公司管辖的服务区数量，并按数量降序排序。",
    "sql": "SELECT company_name AS 公司名称, COUNT(*) AS 管辖服务区数量 FROM bss_service_area JOIN bss_company ON company_id = bss_company.id WHERE bss_service_area.delete_ts IS NULL GROUP BY company_name ORDER BY 管辖服务区数量 DESC;"
  },
  {
    "question": "查找所有开放状态的服务区及其所属路线名称。",
    "sql": "SELECT service_area_name AS 服务区名称, route_name AS 路线名称 FROM bss_service_area JOIN bss_section_route_area_link ON bss_service_area.id = service_area_id JOIN bss_section_route ON section_route_id = bss_section_route.id WHERE service_state = '开放' AND bss_service_area.delete_ts IS NULL;"
  },
  {
    "question": "统计每个服务区在2023年4月的总支付金额，并按金额降序排序。",
    "sql": "SELECT service_name AS 服务区名称, SUM(pay_sum) AS 总支付金额 FROM bss_business_day_data WHERE oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND delete_ts IS NULL GROUP BY service_name ORDER BY 总支付金额 DESC;"
  },
  {
    "question": "查询每个服务区关联的路段名称和路线名称。",
    "sql": "SELECT service_area_name AS 服务区名称, section_name AS 路段名称, route_name AS 路线名称 FROM bss_service_area JOIN bss_section_route_area_link ON bss_service_area.id = service_area_id JOIN bss_section_route ON section_route_id = bss_section_route.id WHERE bss_service_area.delete_ts IS NULL;"
  },
  {
    "question": "统计各数据来源类别的服务区数量分布情况",
    "sql": "SELECT source_system_type AS 数据来源类别, COUNT(*) AS 服务区数量 FROM bss_service_area_mapper WHERE delete_ts IS NULL GROUP BY source_system_type ORDER BY 服务区数量 DESC;"
  },
  {
    "question": "查询最近一个月内各数据来源类别新增的服务区数量",
    "sql": "SELECT source_system_type AS 数据来源类别, COUNT(*) AS 新增服务区数量 FROM bss_service_area_mapper WHERE create_ts >= CURRENT_DATE - INTERVAL '1 month' AND delete_ts IS NULL GROUP BY source_system_type ORDER BY 新增服务区数量 DESC;"
  },
  {
    "question": "列出由手工录入来源创建的服务区名称及其编码",
    "sql": "SELECT service_name AS 服务区名称, service_no AS 服务区编码 FROM bss_service_area_mapper WHERE source_system_type = '手工录入' AND delete_ts IS NULL;"
  },
  {
    "question": "统计不同数据来源类别中服务区的状态分布（开放/关闭）",
    "sql": "SELECT mapper.source_system_type AS 数据来源类别, area.service_state AS 服务区状态, COUNT(*) AS 数量 FROM bss_service_area_mapper mapper JOIN bss_service_area area ON mapper.service_area_id = area.id WHERE mapper.delete_ts IS NULL AND area.delete_ts IS NULL GROUP BY mapper.source_system_type, area.service_state ORDER BY 数据来源类别, 服务区状态;"
  },
  {
    "question": "列出最近更新时间在一周内的驿购来源服务区及其更新人",
    "sql": "SELECT service_name AS 服务区名称, service_no AS 服务区编码, updated_by AS 更新人, update_ts AS 更新时间 FROM bss_service_area_mapper WHERE source_system_type = '驿购' AND update_ts >= CURRENT_DATE - INTERVAL '7 days' AND delete_ts IS NULL ORDER BY 更新时间 DESC LIMIT 10;"
  },
  {
    "question": "查询数据来源类别为驿美且所属公司为宜春分公司的服务区数量",
    "sql": "SELECT COUNT(*) AS 服务区数量 FROM bss_service_area_mapper mapper JOIN bss_service_area area ON mapper.service_area_id = area.id JOIN bss_company company ON area.company_id = company.id WHERE mapper.source_system_type = '驿美' AND company.company_name = '宜春分公司' AND mapper.delete_ts IS NULL AND area.delete_ts IS NULL AND company.delete_ts IS NULL;"
  },
  {
    "question": "按数据来源类别统计服务区的平均版本号，查看数据更新频率",
    "sql": "SELECT source_system_type AS 数据来源类别, AVG(version) AS 平均版本号 FROM bss_service_area_mapper WHERE delete_ts IS NULL GROUP BY source_system_type ORDER BY 平均版本号 DESC;"
  },
  {
    "question": "找出创建人最多的服务区数据来源类别及其对应创建人",
    "sql": "SELECT source_system_type AS 数据来源类别, created_by AS 创建人, COUNT(*) AS 创建数量 FROM bss_service_area_mapper WHERE delete_ts IS NULL GROUP BY source_system_type, created_by ORDER BY 创建数量 DESC LIMIT 1;"
  },
  {
    "question": "对比不同数据来源类别的服务区数量和平均版本号",
    "sql": "SELECT source_system_type AS 数据来源类别, COUNT(*) AS 服务区数量, AVG(version) AS 平均版本号 FROM bss_service_area_mapper WHERE delete_ts IS NULL GROUP BY source_system_type ORDER BY 服务区数量 DESC;"
  },
  {
    "question": "列出所有由驿购和驿美来源创建且未删除的服务区信息",
    "sql": "SELECT service_name AS 服务区名称, service_no AS 服务区编码, source_system_type AS 数据来源类别 FROM bss_service_area_mapper WHERE source_system_type IN ('驿购', '驿美') AND delete_ts IS NULL;"
  }
]