[
  {
    "question": "查询2023年4月1日各个服务区的总收入、总订单数并按收入从高到低排序",
    "sql": "SELECT service_name AS 服务区名称, SUM(pay_sum) 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;"
  },
  {
    "question": "查询2023年4月1日各个档口的微信支付金额及订单数并按金额从高到低排序",
    "sql": "SELECT branch_name AS 档口名称, wx AS 微信支付金额, wx_order AS 微信订单数 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY 微信支付金额 DESC;"
  },
  {
    "question": "统计2023年4月1日各支付方式的总金额占比",
    "sql": "SELECT '微信' AS 支付方式, SUM(wx) / SUM(pay_sum) * 100 AS 占比百分比 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '支付宝', SUM(zfb) / SUM(pay_sum) * 100 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '现金', SUM(rmb) / SUM(pay_sum) * 100 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '行吧', SUM(xs) / SUM(pay_sum) * 100 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL;"
  },
  {
    "question": "查询2023年4月各服务区的平均日收入并按收入从高到低排序",
    "sql": "SELECT service_name AS 服务区名称, AVG(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": "查询2023年4月1日订单数最多的前5个档口",
    "sql": "SELECT branch_name AS 档口名称, order_sum AS 订单总数 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY order_sum DESC LIMIT 5;"
  },
  {
    "question": "查询2023年4月1日现金支付金额最高的服务区",
    "sql": "SELECT service_name AS 服务区名称, rmb AS 现金支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY 现金支付金额 DESC LIMIT 1;"
  },
  {
    "question": "统计2023年4月各服务区每日收入趋势并按日期排序",
    "sql": "SELECT oper_date AS 统计日期, 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 oper_date, service_name ORDER BY 统计日期;"
  },
  {
    "question": "查询2023年4月1日各服务区现金支付订单数排名前3",
    "sql": "SELECT service_name AS 服务区名称, rmb_order AS 现金订单数 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY 现金订单数 DESC LIMIT 3;"
  },
  {
    "question": "查询2023年4月1日各档口支付宝支付金额为0的明细",
    "sql": "SELECT branch_name AS 档口名称, zfb AS 支付宝支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND zfb = 0 AND delete_ts IS NULL;"
  },
  {
    "question": "统计2023年4月各服务区微信支付订单数的月总和并按总和从高到低排序",
    "sql": "SELECT service_name AS 服务区名称, SUM(wx_order) 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 count_date AS 统计日期, service_area_name AS 服务区名称, SUM(customer_count) AS 总车流量 FROM bss_car_day_count LEFT JOIN bss_service_area ON bss_car_day_count.service_area_id = bss_service_area.id WHERE bss_car_day_count.delete_ts IS NULL GROUP BY count_date, service_area_name ORDER BY count_date, service_area_name;"
  },
  {
    "question": "分析2023年4月1日各车辆类型的总占比情况。",
    "sql": "SELECT car_type AS 车辆类型, SUM(customer_count) AS 总数量 FROM bss_car_day_count WHERE count_date = '2023-04-01' AND delete_ts IS NULL GROUP BY car_type;"
  },
  {
    "question": "找出2023年3月每日车流量趋势，按日期升序排列。",
    "sql": "SELECT count_date AS 日期, SUM(customer_count) AS 总车流量 FROM bss_car_day_count WHERE count_date BETWEEN '2023-03-01' AND '2023-03-31' AND delete_ts IS NULL GROUP BY count_date ORDER BY 日期 ASC;"
  },
  {
    "question": "查询2023年4月1日车流量最高的前5个服务区。",
    "sql": "SELECT service_area_name AS 服务区名称, SUM(customer_count) AS 总车流量 FROM bss_car_day_count LEFT JOIN bss_service_area ON bss_car_day_count.service_area_id = bss_service_area.id WHERE count_date = '2023-04-01' AND bss_car_day_count.delete_ts IS NULL GROUP BY service_area_name ORDER BY 总车流量 DESC LIMIT 5;"
  },
  {
    "question": "统计2023年每月各服务区的平均日车流量。",
    "sql": "SELECT service_area_name AS 服务区名称, DATE_TRUNC('month', count_date) AS 月份, AVG(daily_count) AS 平均日车流量 FROM (SELECT service_area_name, count_date, SUM(customer_count) AS daily_count FROM bss_car_day_count LEFT JOIN bss_service_area ON bss_car_day_count.service_area_id = bss_service_area.id WHERE count_date BETWEEN '2023-01-01' AND '2023-12-31' AND bss_car_day_count.delete_ts IS NULL GROUP BY service_area_name, count_date) AS daily_data GROUP BY service_area_name, 月份 ORDER BY 月份, 服务区名称;"
  },
  {
    "question": "查询2023年4月1日各车辆类型在各服务区的分布情况。",
    "sql": "SELECT bss_service_area.service_area_name AS 服务区名称, bss_car_day_count.car_type AS 车辆类型, SUM(bss_car_day_count.customer_count) AS 数量 FROM bss_car_day_count LEFT JOIN bss_service_area ON bss_car_day_count.service_area_id = bss_service_area.id WHERE count_date = '2023-04-01' AND bss_car_day_count.delete_ts IS NULL GROUP BY bss_service_area.service_area_name, bss_car_day_count.car_type ORDER BY bss_service_area.service_area_name, bss_car_day_count.car_type;"
  },
  {
    "question": "分析2023年3月车流量最少的3个服务区。",
    "sql": "SELECT service_area_name AS 服务区名称, SUM(customer_count) AS 总车流量 FROM bss_car_day_count LEFT JOIN bss_service_area ON bss_car_day_count.service_area_id = bss_service_area.id WHERE count_date BETWEEN '2023-03-01' AND '2023-03-31' AND bss_car_day_count.delete_ts IS NULL GROUP BY service_area_name ORDER BY 总车流量 ASC LIMIT 3;"
  },
  {
    "question": "查询2023年4月1日各服务区不同车辆类型的危化品车流量。",
    "sql": "SELECT bss_service_area.service_area_name AS 服务区名称, SUM(bss_car_day_count.customer_count) AS 危化品车流量 FROM bss_car_day_count LEFT JOIN bss_service_area ON bss_car_day_count.service_area_id = bss_service_area.id WHERE count_date = '2023-04-01' AND car_type = '危化品' AND bss_car_day_count.delete_ts IS NULL GROUP BY bss_service_area.service_area_name ORDER BY 服务区名称;"
  },
  {
    "question": "统计2023年3月每日平均车流量，并按星期几分组分析趋势。",
    "sql": "SELECT EXTRACT(ISODOW FROM count_date) AS 星期, AVG(daily_count) AS 平均日车流量 FROM (SELECT count_date, SUM(customer_count) AS daily_count FROM bss_car_day_count WHERE count_date BETWEEN '2023-03-01' AND '2023-03-31' AND delete_ts IS NULL GROUP BY count_date) AS daily_data GROUP BY 星期 ORDER BY 星期;"
  },
  {
    "question": "统计各分公司在2023年4月1日当天的总营收，并按营收从高到低排序。",
    "sql": "SELECT comp.company_name AS 公司名称, SUM(bdd.pay_sum) AS 当日总营收 FROM bss_service_area sa JOIN bss_business_day_data bdd ON sa.service_area_no = bdd.service_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name ORDER BY 当日总营收 DESC;"
  },
  {
    "question": "列出各分公司下属服务区在2023年4月1日的营收明细，包括服务区名称、公司名称和营收金额。",
    "sql": "SELECT bdd.service_name AS 服务区名称, comp.company_name AS 公司名称, SUM(bdd.pay_sum) AS 营收金额 FROM bss_business_day_data bdd JOIN bss_service_area sa ON bdd.service_no = sa.service_area_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY bdd.service_name, comp.company_name;"
  },
  {
    "question": "统计各分公司在2023年第一季度（1月到3月）的总营收排名。",
    "sql": "SELECT comp.company_name AS 公司名称, SUM(bdd.pay_sum) AS 总营收 FROM bss_service_area sa JOIN bss_business_day_data bdd ON sa.service_area_no = bdd.service_no AND bdd.oper_date BETWEEN '2023-01-01' AND '2023-03-31' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name ORDER BY 总营收 DESC;"
  },
  {
    "question": "统计各分公司在2023年4月1日的平均日营收，并按平均营收从高到低排序。",
    "sql": "SELECT comp.company_name AS 公司名称, AVG(bdd.pay_sum) AS 平均日营收 FROM bss_service_area sa JOIN bss_business_day_data bdd ON sa.service_area_no = bdd.service_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name ORDER BY 平均日营收 DESC;"
  },
  {
    "question": "列出2023年4月1日营收最高的前5个服务区及其所属公司。",
    "sql": "SELECT bdd.service_name AS 服务区名称, comp.company_name AS 所属公司, SUM(bdd.pay_sum) AS 营收金额 FROM bss_business_day_data bdd JOIN bss_service_area sa ON bdd.service_no = sa.service_area_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY bdd.service_name, comp.company_name ORDER BY 营收金额 DESC LIMIT 5;"
  },
  {
    "question": "统计各分公司在2023年4月1日的订单总数，并按订单数从高到低排序。",
    "sql": "SELECT comp.company_name AS 公司名称, SUM(bdd.order_sum) AS 当日订单总数 FROM bss_service_area sa JOIN bss_business_day_data bdd ON sa.service_area_no = bdd.service_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name ORDER BY 当日订单总数 DESC;"
  },
  {
    "question": "统计各分公司在2023年4月1日的现金支付总额，并按金额从高到低排序。",
    "sql": "SELECT comp.company_name AS 公司名称, SUM(bdd.rmb) AS 现金支付总额 FROM bss_service_area sa JOIN bss_business_day_data bdd ON sa.service_area_no = bdd.service_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name ORDER BY 现金支付总额 DESC;"
  },
  {
    "question": "统计各分公司在2023年4月1日的微信支付总额，并按金额从高到低排序。",
    "sql": "SELECT comp.company_name AS 公司名称, SUM(bdd.wx) AS 微信支付总额 FROM bss_service_area sa JOIN bss_business_day_data bdd ON sa.service_area_no = bdd.service_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name ORDER BY 微信支付总额 DESC;"
  },
  {
    "question": "统计各分公司在2023年4月1日的支付宝支付总额，并按金额从高到低排序。",
    "sql": "SELECT comp.company_name AS 公司名称, SUM(bdd.zfb) AS 支付宝支付总额 FROM bss_service_area sa JOIN bss_business_day_data bdd ON sa.service_area_no = bdd.service_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name ORDER BY 支付宝支付总额 DESC;"
  },
  {
    "question": "列出2023年4月1日所有服务区的营收明细，并按公司分组。",
    "sql": "SELECT comp.company_name AS 公司名称, bdd.service_name AS 服务区名称, SUM(bdd.pay_sum) AS 营收金额 FROM bss_business_day_data bdd JOIN bss_service_area sa ON bdd.service_no = sa.service_area_no AND bdd.oper_date = '2023-04-01' AND bdd.delete_ts IS NULL JOIN bss_company comp ON sa.company_id = comp.id AND comp.delete_ts IS NULL GROUP BY comp.company_name, bdd.service_name ORDER BY 公司名称, 营收金额 DESC;"
  },
  {
    "question": "统计各路线关联的服务区数量，并按数量降序排列。",
    "sql": "SELECT bsr.route_name AS 路线名称, COUNT(bsral.service_area_id) AS 服务区数量 FROM bss_section_route bsr LEFT JOIN bss_section_route_area_link bsral ON bsr.id = bsral.section_route_id AND bsr.delete_ts IS NULL WHERE bsr.delete_ts IS NULL GROUP BY bsr.route_name ORDER BY 服务区数量 DESC;"
  },
  {
    "question": "列出所有路线及其对应的服务区名称，按路线名称排序。",
    "sql": "SELECT bsr.route_name AS 路线名称, bsa.service_area_name AS 服务区名称 FROM bss_section_route bsr JOIN bss_section_route_area_link bsral ON bsr.id = bsral.section_route_id JOIN bss_service_area bsa ON bsral.service_area_id = bsa.id WHERE bsr.delete_ts IS NULL AND bsa.delete_ts IS NULL ORDER BY 路线名称;"
  },
  {
    "question": "查询2023年4月1日某服务区的微信支付金额和订单数量。",
    "sql": "SELECT service_name AS 服务区名称, wx AS 微信支付金额, wx_order AS 微信订单数量 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND service_name = '宜春服务区' AND delete_ts IS NULL;"
  },
  {
    "question": "统计2022年进入各服务区的车辆总数，并按数量降序排列。",
    "sql": "SELECT service_area_id AS 服务区ID, SUM(customer_count) AS 车辆总数 FROM bss_car_day_count WHERE count_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY service_area_id ORDER BY 车辆总数 DESC;"
  },
  {
    "question": "列出所有开放状态的服务区及其所属路线。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, bsr.route_name AS 路线名称 FROM bss_service_area bsa JOIN bss_section_route_area_link bsral ON bsa.id = bsral.service_area_id JOIN bss_section_route bsr ON bsral.section_route_id = bsr.id WHERE bsa.service_state = '开放' AND bsa.delete_ts IS NULL AND bsr.delete_ts IS NULL;"
  },
  {
    "question": "统计每个公司管辖的服务区数量，并按数量降序排列。",
    "sql": "SELECT bc.company_name AS 公司名称, COUNT(bsa.id) AS 服务区数量 FROM bss_company bc LEFT JOIN bss_service_area bsa ON bc.id = bsa.company_id AND bsa.delete_ts IS NULL GROUP BY bc.company_name ORDER BY 服务区数量 DESC;"
  },
  {
    "question": "找出2023年4月1日支付总金额最高的前10个服务区。",
    "sql": "SELECT service_name AS 服务区名称, pay_sum AS 支付总金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY pay_sum DESC LIMIT 10;"
  },
  {
    "question": "统计各路线在2022年进入服务区的车辆总数，并按路线排序。",
    "sql": "SELECT bsr.route_name AS 路线名称, SUM(car.customer_count) AS 车辆总数 FROM bss_section_route bsr JOIN bss_section_route_area_link bsral ON bsr.id = bsral.section_route_id JOIN bss_car_day_count car ON bsral.service_area_id = car.service_area_id WHERE car.count_date BETWEEN '2022-01-01' AND '2022-12-31' GROUP BY bsr.route_name ORDER BY 路线名称;"
  },
  {
    "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 service_no AS 服务区编码, service_name AS 服务区名称 FROM bss_service_area_mapper WHERE source_system_type = '驿购' AND delete_ts IS NULL;"
  },
  {
    "question": "统计每个数据来源类别ID对应的服务区数量，并按数量降序排列",
    "sql": "SELECT source_type AS 数据来源类别ID, COUNT(*) AS 服务区数量 FROM bss_service_area_mapper WHERE delete_ts IS NULL GROUP BY source_type ORDER BY 服务区数量 DESC;"
  },
  {
    "question": "查询最近一周内创建的数据来源为驿美的服务区信息",
    "sql": "SELECT service_name AS 服务区名称, service_no AS 服务区编码, create_ts AS 创建时间 FROM bss_service_area_mapper WHERE source_system_type = '驿美' AND create_ts >= NOW() - INTERVAL '7 days' AND delete_ts IS NULL;"
  },
  {
    "question": "列出数据来源类别ID为1且状态为开放的服务区名称和编码",
    "sql": "SELECT sa.service_area_name AS 服务区名称, sa.service_area_no AS 服务区编码 FROM bss_service_area sa JOIN bss_service_area_mapper sam ON sa.service_area_no = sam.service_no WHERE sam.source_type = 1 AND sa.service_state = '开放' AND sa.delete_ts IS NULL;"
  },
  {
    "question": "统计各数据来源在最近一个月内新增的服务区数量",
    "sql": "SELECT source_system_type AS 数据来源, COUNT(*) AS 新增服务区数量 FROM bss_service_area_mapper WHERE create_ts >= NOW() - INTERVAL '1 month' AND delete_ts IS NULL GROUP BY source_system_type ORDER BY 新增服务区数量 DESC;"
  },
  {
    "question": "找出没有被任何数据来源覆盖的服务区信息",
    "sql": "SELECT sa.service_area_name AS 服务区名称, sa.service_area_no AS 服务区编码 FROM bss_service_area sa LEFT JOIN bss_service_area_mapper sam ON sa.service_area_no = sam.service_no WHERE sam.id IS NULL AND sa.delete_ts IS NULL;"
  },
  {
    "question": "统计各数据来源的覆盖比例，即每个来源服务区数量占总数的比例",
    "sql": "SELECT source_system_type AS 数据来源, COUNT(*) * 100.0 / (SELECT COUNT(*) FROM bss_service_area_mapper WHERE delete_ts IS NULL) AS 覆盖比例 FROM bss_service_area_mapper WHERE delete_ts IS NULL GROUP BY source_system_type;"
  },
  {
    "question": "列出数据来源为手工录入且创建时间在2023年之后的服务区信息",
    "sql": "SELECT service_name AS 服务区名称, service_no AS 服务区编码, create_ts AS 创建时间 FROM bss_service_area_mapper WHERE source_system_type = '手工录入' AND create_ts >= '2023-01-01' AND delete_ts IS NULL;"
  },
  {
    "question": "获取数据来源中服务区数量最多的前3个来源及其数量",
    "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 LIMIT 3;"
  }
]