[
  {
    "question": "查询2023年4月1日各服务区的总收入、订单总量并按收入从高到低排序。",
    "sql": "SELECT service_name AS 服务区名称, pay_sum AS 总收入, order_sum AS 订单总量 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL GROUP BY service_name, pay_sum, order_sum ORDER BY pay_sum DESC;"
  },
  {
    "question": "统计2023年4月1日各支付方式的总金额及订单数量，并按微信支付金额降序排序。",
    "sql": "SELECT '微信' AS 支付方式, SUM(wx) AS 总金额, SUM(wx_order) AS 订单数量 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '支付宝', SUM(zfb), SUM(zf_order) FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL UNION ALL SELECT '现金', SUM(rmb), SUM(rmb_order) FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY 总金额 DESC;"
  },
  {
    "question": "查询2023年4月1日至2023年4月7日庐山服务区每日总收入并展示收入趋势。",
    "sql": "SELECT oper_date AS 统计日期, pay_sum AS 总收入 FROM bss_business_day_data WHERE service_name = '庐山服务区' AND oper_date BETWEEN '2023-04-01' AND '2023-04-07' AND delete_ts IS NULL ORDER BY oper_date;"
  },
  {
    "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 ORDER BY 微信支付占比 DESC;"
  },
  {
    "question": "查询2023年4月1日订单总量最高的前5个服务区及其订单数量。",
    "sql": "SELECT service_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 branch_name AS 档口名称, pay_sum AS 收入总和 FROM bss_business_day_data WHERE service_name = '宜春服务区' AND oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY 收入总和 DESC;"
  },
  {
    "question": "查询2023年4月1日各服务区现金支付金额超过1000元的服务区名称及其金额。",
    "sql": "SELECT service_name AS 服务区名称, rmb AS 现金支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND rmb > 1000 AND delete_ts IS NULL ORDER BY 现金支付金额 DESC;"
  },
  {
    "question": "查询2023年4月1日各服务区支付宝订单数量为0的服务区名称及其总收入。",
    "sql": "SELECT service_name AS 服务区名称, pay_sum AS 总收入 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND zf_order = 0 AND delete_ts IS NULL ORDER BY 总收入 DESC;"
  },
  {
    "question": "查询2023年4月1日各服务区行吧支付金额大于0的服务区名称及行吧支付金额。",
    "sql": "SELECT service_name AS 服务区名称, xs AS 行吧支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND xs > 0 AND delete_ts IS NULL ORDER BY 行吧支付金额 DESC;"
  },
  {
    "question": "查询2023年4月1日金豆支付订单数量大于0的服务区名称及金豆支付金额。",
    "sql": "SELECT service_name AS 服务区名称, jd AS 金豆支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND jd_order > 0 AND delete_ts IS NULL ORDER BY 金豆支付金额 DESC;"
  },
  {
    "question": "统计2023年4月每日车辆总数及趋势，按日期升序排列；",
    "sql": "SELECT count_date AS 统计日期, SUM(customer_count) AS 车辆总数 FROM bss_car_day_count WHERE delete_ts IS NULL AND count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY count_date ORDER BY 统计日期 ASC;"
  },
  {
    "question": "查询各服务区2023年4月累计车流量TOP 5，按车辆总数降序排列；",
    "sql": "SELECT sa.service_area_name AS 服务区名称, SUM(cd.customer_count) AS 车辆总数 FROM bss_car_day_count cd JOIN bss_service_area sa ON cd.service_area_id = sa.id WHERE cd.delete_ts IS NULL AND sa.delete_ts IS NULL AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY sa.service_area_name ORDER BY 车辆总数 DESC LIMIT 5;"
  },
  {
    "question": "分析2023年4月各车辆类型占比（占总车流量百分比），结果按占比降序展示；",
    "sql": "SELECT car_type AS 车辆类型, ROUND(100.0 * SUM(customer_count) / (SELECT SUM(customer_count) FROM bss_car_day_count WHERE delete_ts IS NULL AND count_date BETWEEN '2023-04-01' AND '2023-04-30'), 2) AS 占比百分比 FROM bss_car_day_count WHERE delete_ts IS NULL AND count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY car_type ORDER BY 占比百分比 DESC;"
  },
  {
    "question": "查询2023年4月危化品车辆出现次数大于3的服务区及其频次；",
    "sql": "SELECT sa.service_area_name AS 服务区名称, COUNT(*) AS 危化品车出现天数 FROM bss_car_day_count cd JOIN bss_service_area sa ON cd.service_area_id = sa.id WHERE cd.delete_ts IS NULL AND sa.delete_ts IS NULL AND cd.car_type = '危化品' AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY sa.service_area_name HAVING COUNT(*) > 3;"
  },
  {
    "question": "查看宜春服务区2023年4月每日车辆明细，包括车辆类型和数量；",
    "sql": "SELECT cd.count_date AS 统计日期, cd.car_type AS 车辆类型, cd.customer_count AS 车辆数量 FROM bss_car_day_count cd JOIN bss_service_area sa ON cd.service_area_id = sa.id WHERE cd.delete_ts IS NULL AND sa.delete_ts IS NULL AND sa.service_area_name = '宜春服务区' AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' ORDER BY cd.count_date;"
  },
  {
    "question": "统计各公司管辖的服务区平均日车流量（基于2023年4月数据），按均值降序排列；",
    "sql": "SELECT c.company_name AS 公司名称, ROUND(AVG(daily_sum), 2) AS 平均日车流量 FROM (SELECT sa.company_id, cd.count_date, SUM(cd.customer_count) AS daily_sum FROM bss_car_day_count cd JOIN bss_service_area sa ON cd.service_area_id = sa.id WHERE cd.delete_ts IS NULL AND sa.delete_ts IS NULL AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY sa.company_id, cd.count_date) t JOIN bss_company c ON t.company_id = c.id WHERE c.delete_ts IS NULL GROUP BY c.company_name ORDER BY 平均日车流量 DESC;"
  },
  {
    "question": "找出2023年4月单日车流量最高的服务区及对应日期和数量；",
    "sql": "SELECT sa.service_area_name AS 服务区名称, cd.count_date AS 统计日期, cd.customer_count AS 车辆数量 FROM bss_car_day_count cd JOIN bss_service_area sa ON cd.service_area_id = sa.id WHERE cd.delete_ts IS NULL AND sa.delete_ts IS NULL AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' ORDER BY cd.customer_count DESC LIMIT 1;"
  },
  {
    "question": "对比2023年4月开放状态与关闭状态服务区的总车流量差异；",
    "sql": "SELECT sa.service_state AS 服务区状态, COALESCE(SUM(cd.customer_count), 0) AS 总车流量 FROM bss_service_area sa LEFT JOIN bss_car_day_count cd ON sa.id = cd.service_area_id AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' WHERE sa.delete_ts IS NULL GROUP BY sa.service_state;"
  },
  {
    "question": "统计2023年4月每天过境车辆数量变化趋势，用于判断高峰日；",
    "sql": "SELECT count_date AS 统计日期, SUM(customer_count) AS 过境车辆数 FROM bss_car_day_count WHERE delete_ts IS NULL AND car_type = '过境' AND count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY count_date ORDER BY 统计日期;"
  },
  {
    "question": "查询2023年4月无任何车辆记录的服务区列表（即沉默服务区）；",
    "sql": "SELECT service_area_name AS 服务区名称 FROM bss_service_area WHERE delete_ts IS NULL AND id NOT IN (SELECT DISTINCT service_area_id FROM bss_car_day_count WHERE delete_ts IS NULL AND count_date BETWEEN '2023-04-01' AND '2023-04-30') AND service_state = '开放';"
  },
  {
    "question": "各公司管理的服务区在2023年4月的平均每日营收是多少？按营收从高到低排序。",
    "sql": "SELECT c.company_name AS 公司名称, AVG(b.pay_sum) AS 平均每日营收 FROM bss_company c JOIN bss_service_area s ON c.id = s.company_id JOIN bss_business_day_data b ON s.service_area_no = b.service_no WHERE b.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND c.delete_ts IS NULL AND s.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY c.company_name ORDER BY 平均每日营收 DESC;"
  },
  {
    "question": "2023年4月，哪家公司管理的服务区总订单数最多？列出前5名。",
    "sql": "SELECT c.company_name AS 公司名称, SUM(b.order_sum) AS 总订单数 FROM bss_company c JOIN bss_service_area s ON c.id = s.company_id JOIN bss_business_day_data b ON s.service_area_no = b.service_no WHERE b.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND c.delete_ts IS NULL AND s.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY c.company_name ORDER BY 总订单数 DESC LIMIT 5;"
  },
  {
    "question": "各公司旗下服务区在2023年4月的车辆流量总和是多少？按车辆数降序排列。",
    "sql": "SELECT co.company_name AS 公司名称, SUM(car.customer_count) AS 车辆流量总和 FROM bss_company co JOIN bss_service_area sa ON co.id = sa.company_id JOIN bss_car_day_count car ON sa.id = car.service_area_id WHERE car.count_date BETWEEN '2023-04-01' AND '2023-04-30' AND co.delete_ts IS NULL AND sa.delete_ts IS NULL AND car.delete_ts IS NULL GROUP BY co.company_name ORDER BY 车辆流量总和 DESC;"
  },
  {
    "question": "2023年4月，各公司管理的服务区日均车辆流量与平均营收的关系如何？",
    "sql": "SELECT co.company_name AS 公司名称, AVG(car.customer_count) AS 日均车辆流量, AVG(bd.pay_sum) AS 日均营收 FROM bss_company co JOIN bss_service_area sa ON co.id = sa.company_id JOIN bss_car_day_count car ON sa.id = car.service_area_id JOIN bss_business_day_data bd ON sa.service_area_no = bd.service_no WHERE bd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND car.count_date = bd.oper_date AND co.delete_ts IS NULL AND sa.delete_ts IS NULL AND car.delete_ts IS NULL AND bd.delete_ts IS NULL GROUP BY co.company_name ORDER BY 日均营收 DESC;"
  },
  {
    "question": "宜春分公司和上饶分公司在2023年4月的每日营收趋势对比（按日期分组）。",
    "sql": "SELECT bd.oper_date AS 统计日期, c.company_name AS 公司名称, SUM(bd.pay_sum) AS 当日总营收 FROM bss_company c JOIN bss_service_area s ON c.id = s.company_id JOIN bss_business_day_data bd ON s.service_area_no = bd.service_no WHERE c.company_name IN ('宜春分公司', '上饶分公司') AND bd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND c.delete_ts IS NULL AND s.delete_ts IS NULL AND bd.delete_ts IS NULL GROUP BY bd.oper_date, c.company_name ORDER BY 统计日期, 公司名称;"
  },
  {
    "question": "各公司管理的服务区在2023年4月平均每辆车带来的营收是多少？按效率排序。",
    "sql": "SELECT co.company_name AS 公司名称, SUM(bd.pay_sum) / NULLIF(SUM(car.customer_count), 0) AS 单车营收效率 FROM bss_company co JOIN bss_service_area sa ON co.id = sa.company_id JOIN bss_business_day_data bd ON sa.service_area_no = bd.service_no JOIN bss_car_day_count car ON sa.id = car.service_area_id WHERE bd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND car.count_date = bd.oper_date AND co.delete_ts IS NULL AND sa.delete_ts IS NULL AND bd.delete_ts IS NULL AND car.delete_ts IS NULL GROUP BY co.company_name ORDER BY 单车营收效率 DESC;"
  },
  {
    "question": "2023年4月，各公司管理的服务区中，哪个服务区平均营收最高？仅显示每个公司的Top1。",
    "sql": "WITH ranked AS (SELECT co.company_name AS 公司名称, sa.service_area_name AS 服务区名称, AVG(bd.pay_sum) AS 平均营收, ROW_NUMBER() OVER (PARTITION BY co.id ORDER BY AVG(bd.pay_sum) DESC) AS rn FROM bss_company co JOIN bss_service_area sa ON co.id = sa.company_id JOIN bss_business_day_data bd ON sa.service_area_no = bd.service_no WHERE bd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND co.delete_ts IS NULL AND sa.delete_ts IS NULL AND bd.delete_ts IS NULL GROUP BY co.company_name, sa.service_area_name, co.id) SELECT 公司名称, 服务区名称, 平均营收 FROM ranked WHERE rn = 1;"
  },
  {
    "question": "各公司在2023年4月管理的服务区数量及其总营收、总订单数。",
    "sql": "SELECT c.company_name AS 公司名称, COUNT(DISTINCT s.id) AS 管辖服务区数量, SUM(b.pay_sum) AS 总营收, SUM(b.order_sum) AS 总订单数 FROM bss_company c JOIN bss_service_area s ON c.id = s.company_id JOIN bss_business_day_data b ON s.service_area_no = b.service_no WHERE b.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND c.delete_ts IS NULL AND s.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY c.company_name ORDER BY 总营收 DESC;"
  },
  {
    "question": "2023年4月，各公司旗下服务区的现金订单占比（现金订单数/总订单数）是多少？按占比排序。",
    "sql": "SELECT c.company_name AS 公司名称, SUM(b.rmb_order) * 1.0 / NULLIF(SUM(b.order_sum), 0) AS 现金订单占比 FROM bss_company c JOIN bss_service_area s ON c.id = s.company_id JOIN bss_business_day_data b ON s.service_area_no = b.service_no WHERE b.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND c.delete_ts IS NULL AND s.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY c.company_name ORDER BY 现金订单占比 DESC;"
  },
  {
    "question": "哪些公司在2023年4月有服务区出现过单日营收低于1000元的情况？列出公司及对应天数。",
    "sql": "SELECT c.company_name AS 公司名称, COUNT(*) AS 低营收天数 FROM bss_company c JOIN bss_service_area s ON c.id = s.company_id JOIN bss_business_day_data b ON s.service_area_no = b.service_no WHERE b.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND b.pay_sum < 1000 AND c.delete_ts IS NULL AND s.delete_ts IS NULL AND b.delete_ts IS NULL GROUP BY c.company_name ORDER BY 低营收天数 DESC;"
  },
  {
    "question": "查询2023年4月1日各服务区总营收（支付金额）排名前5的服务区名称及营收金额。",
    "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 LIMIT 5;"
  },
  {
    "question": "分析昌九路段下所有服务区在2023年4月的日均车辆流量（按城际车类别），用于评估该路段车流特征。",
    "sql": "SELECT sa.service_area_name AS 服务区名称, AVG(cd.customer_count) AS 日均城际车流量 FROM bss_section_route sr JOIN bss_section_route_area_link sral ON sr.id = sral.section_route_id JOIN bss_service_area sa ON sral.service_area_id = sa.id JOIN bss_car_day_count cd ON sa.id = cd.service_area_id WHERE sr.section_name = '昌九' AND cd.car_type = '城际' AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' AND sr.delete_ts IS NULL AND sa.delete_ts IS NULL AND cd.delete_ts IS NULL GROUP BY sa.service_area_name;"
  },
  {
    "question": "查询2023年4月微信支付金额占总支付金额比例超过50%的服务区名称及其占比。",
    "sql": "SELECT service_name AS 服务区名称, (SUM(wx) / SUM(pay_sum)) * 100 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 HAVING (SUM(wx) / SUM(pay_sum)) > 0.5 ORDER BY 微信支付占比 DESC;"
  },
  {
    "question": "找出2023年4月单日订单总数最高的服务区及对应日期，用于识别高峰服务能力。",
    "sql": "SELECT service_name AS 服务区名称, oper_date AS 统计日期, order_sum AS 订单总数 FROM bss_business_day_data WHERE oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND delete_ts IS NULL ORDER BY order_sum DESC LIMIT 1;"
  },
  {
    "question": "计算各服务区2023年4月现金支付金额占总支付金额的平均比例，并按比例升序排列，反映无现金化程度。",
    "sql": "SELECT service_name AS 服务区名称, AVG(rmb / NULLIF(pay_sum, 0)) 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 现金支付占比 ASC;"
  },
  {
    "question": "统计2023年4月各服务区危化品车辆出现天数，用于安全风险评估。",
    "sql": "SELECT sa.service_area_name AS 服务区名称, COUNT(DISTINCT cd.count_date) AS 危化品车辆出现天数 FROM bss_service_area sa JOIN bss_car_day_count cd ON sa.id = cd.service_area_id WHERE cd.car_type = '危化品' AND cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' AND sa.delete_ts IS NULL AND cd.delete_ts IS NULL GROUP BY sa.service_area_name ORDER BY 危化品车辆出现天数 DESC;"
  },
  {
    "question": "统计最近一周各服务区的微信支付占比，按服务区名称排序。",
    "sql": "SELECT service_name AS 服务区名称, SUM(wx) / SUM(pay_sum) * 100 AS 微信支付占比 FROM bss_business_day_data WHERE oper_date >= CURRENT_DATE - 7 AND delete_ts IS NULL GROUP BY service_name ORDER BY 服务区名称;"
  },
  {
    "question": "找出2023年4月1日当天，支付宝支付金额最高的前5个服务区。",
    "sql": "SELECT service_name AS 服务区名称, zfb AS 支付宝支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY zfb DESC LIMIT 5;"
  },
  {
    "question": "计算2023年4月各服务区现金支付金额的总和，并按金额从高到低排序。",
    "sql": "SELECT service_name AS 服务区名称, SUM(rmb) 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年各季度不同服务区微信支付订单数量的变化趋势。",
    "sql": "SELECT service_name AS 服务区名称, EXTRACT(QUARTER FROM oper_date) AS 季度, SUM(wx_order) AS 微信订单总数 FROM bss_business_day_data WHERE EXTRACT(YEAR FROM oper_date) = 2023 AND delete_ts IS NULL GROUP BY 服务区名称, 季度 ORDER BY 服务区名称, 季度;"
  },
  {
    "question": "列出2023年4月1日各档口微信、支付宝、现金支付金额的占比情况。",
    "sql": "SELECT branch_name AS 档口名称, wx / pay_sum * 100 AS 微信占比, zfb / pay_sum * 100 AS 支付宝占比, rmb / pay_sum * 100 AS 现金占比 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL;"
  },
  {
    "question": "找出最近一周各服务区微信支付占比的平均值，并筛选出平均占比超过50%的服务区。",
    "sql": "SELECT service_name AS 服务区名称, AVG(wx / pay_sum * 100) AS 平均微信占比 FROM bss_business_day_data WHERE oper_date >= CURRENT_DATE - 7 AND delete_ts IS NULL GROUP BY service_name HAVING AVG(wx / pay_sum * 100) > 50 ORDER BY 平均微信占比 DESC;"
  },
  {
    "question": "列出2023年4月1日当天各服务区微信、支付宝、现金支付金额的明细。",
    "sql": "SELECT service_name AS 服务区名称, wx AS 微信支付金额, zfb AS 支付宝支付金额, rmb AS 现金支付金额 FROM bss_business_day_data WHERE oper_date = '2023-04-01' AND delete_ts IS NULL ORDER BY service_name;"
  },
  {
    "question": "统计2023年4月各服务区各支付方式的支付金额总和，并按总金额排名。",
    "sql": "SELECT service_name AS 服务区名称, '微信' AS 支付方式, SUM(wx) 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 UNION ALL SELECT service_name, '支付宝', SUM(zfb) 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 UNION ALL SELECT service_name, '现金', SUM(rmb) 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月各服务区订单总数的平均值，并按平均值从高到低排序。",
    "sql": "SELECT service_name AS 服务区名称, AVG(order_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月各服务区每日微信支付金额的趋势图数据。",
    "sql": "SELECT service_name AS 服务区名称, oper_date AS 统计日期, wx AS 微信支付金额 FROM bss_business_day_data WHERE oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND delete_ts IS NULL ORDER BY service_name, 统计日期;"
  }
]