[
  {
    "question": "统计最近7天每个服务区的总营业收入和订单数量，按收入降序排列。",
    "sql": "SELECT service_name AS 服务区名称, SUM(pay_sum) AS 总营业收入, SUM(order_sum) AS 总订单数量 FROM bss_business_day_data WHERE oper_date >= CURRENT_DATE - 7 AND delete_ts IS NULL GROUP BY service_name ORDER BY 总营业收入 DESC;"
  },
  {
    "question": "找出2023年4月1日当天营业收入最高的前5个档口及其所属服务区。",
    "sql": "SELECT branch_name AS 档口名称, 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 5;"
  },
  {
    "question": "分析2023年4月各支付方式的使用频率和总金额，按支付方式分类汇总。",
    "sql": "SELECT '微信' AS 支付方式, SUM(wx_order) AS 使用次数, SUM(wx) AS 总金额 FROM bss_business_day_data WHERE oper_date >= '2023-04-01' AND oper_date < '2023-05-01' AND delete_ts IS NULL UNION ALL SELECT '支付宝', SUM(zf_order), SUM(zfb) FROM bss_business_day_data WHERE oper_date >= '2023-04-01' AND oper_date < '2023-05-01' AND delete_ts IS NULL UNION ALL SELECT '现金', SUM(rmb_order), SUM(rmb) FROM bss_business_day_data WHERE oper_date >= '2023-04-01' AND oper_date < '2023-05-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 >= '2023-04-01' AND oper_date <= '2023-04-30' AND delete_ts IS NULL GROUP BY service_name ORDER BY 日均营业收入 DESC;"
  },
  {
    "question": "找出2023年4月10日当天营业收入低于1000元的档口及其所属服务区。",
    "sql": "SELECT branch_name AS 档口名称, service_name AS 服务区名称, pay_sum AS 营业收入 FROM bss_business_day_data WHERE oper_date = '2023-04-10' AND pay_sum < 1000 AND delete_ts IS NULL;"
  },
  {
    "question": "统计2023年4月每个服务区的现金支付订单数量，按订单数量降序排列。",
    "sql": "SELECT service_name AS 服务区名称, SUM(rmb_order) AS 现金支付订单数量 FROM bss_business_day_data WHERE oper_date >= '2023-04-01' AND oper_date <= '2023-04-30' AND delete_ts IS NULL GROUP BY service_name ORDER BY 现金支付订单数量 DESC;"
  },
  {
    "question": "比较2023年4月1日和2023年4月8日两个日期的总营业收入和总订单数量。",
    "sql": "SELECT oper_date AS 统计日期, SUM(pay_sum) AS 总营业收入, SUM(order_sum) AS 总订单数量 FROM bss_business_day_data WHERE oper_date IN ('2023-04-01', '2023-04-08') AND delete_ts IS NULL GROUP BY oper_date;"
  },
  {
    "question": "找出2023年4月支付宝支付金额为0的服务区及其对应的档口数量。",
    "sql": "SELECT service_name AS 服务区名称, COUNT(DISTINCT branch_name) AS 档口数量 FROM bss_business_day_data WHERE oper_date >= '2023-04-01' AND oper_date <= '2023-04-30' AND zfb = 0 AND delete_ts IS NULL GROUP BY service_name;"
  },
  {
    "question": "统计2023年4月每个服务区的微信支付金额占比，并按占比降序排序。",
    "sql": "SELECT service_name AS 服务区名称, SUM(wx) / SUM(pay_sum) * 100 AS 微信支付占比 FROM bss_business_day_data WHERE oper_date >= '2023-04-01' AND oper_date <= '2023-04-30' AND delete_ts IS NULL GROUP BY service_name ORDER BY 微信支付占比 DESC;"
  },
  {
    "question": "列出2023年4月营业收入增长趋势（按日）。",
    "sql": "SELECT oper_date AS 统计日期, SUM(pay_sum) AS 营业收入 FROM bss_business_day_data WHERE oper_date >= '2023-04-01' AND oper_date <= '2023-04-30' AND delete_ts IS NULL GROUP BY oper_date ORDER BY 统计日期;"
  },
  {
    "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 日期;"
  },
  {
    "question": "各车辆类型在2023年4月的占比分布情况如何？",
    "sql": "SELECT car_type AS 车辆类型, SUM(customer_count) AS 总车流量, ROUND(SUM(customer_count)::numeric * 100 / (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月车流量最高的前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 cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY sa.service_area_name ORDER BY 总车流量 DESC LIMIT 5;"
  },
  {
    "question": "城际车辆在各开放状态的服务区中车流量排名如何？",
    "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.car_type = '城际' AND sa.service_state = '开放' GROUP BY sa.service_area_name 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 car_type = '危化品' AND count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY count_date ORDER BY 日期;"
  },
  {
    "question": "每个公司下属服务区在2023年4月的平均日车流量是多少？",
    "sql": "SELECT c.company_name AS 公司名称, AVG(daily_sum) 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 cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY sa.company_id, cd.count_date) sub JOIN bss_company c ON sub.company_id = c.id WHERE c.delete_ts IS NULL GROUP BY c.company_name ORDER BY 平均日车流量 DESC;"
  },
  {
    "question": "2023年4月车流量最低的3个服务区是哪些？",
    "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 cd.count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY sa.service_area_name ORDER BY 总车流量 ASC LIMIT 3;"
  },
  {
    "question": "过境车辆与城际车辆在2023年4月的总量对比情况如何？",
    "sql": "SELECT car_type AS 车辆类型, SUM(customer_count) AS 总车流量 FROM bss_car_day_count WHERE delete_ts IS NULL AND car_type IN ('过境', '城际') AND count_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY car_type ORDER BY 总车流量 DESC;"
  },
  {
    "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 sa.service_area_name AS 服务区名称, SUM(cd.customer_count) AS 本区车流量, ROUND(SUM(cd.customer_count)::numeric * 100 / (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 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;"
  },
  {
    "question": "统计2023年4月1日各公司的总营收金额，并按金额从高到低排序。",
    "sql": "SELECT bc.company_name AS 公司名称, SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date = '2023-04-01' AND bc.delete_ts IS NULL GROUP BY bc.company_name ORDER BY 总营收 DESC;"
  },
  {
    "question": "查询2023年4月各公司每日平均营收金额，并按公司名称排序。",
    "sql": "SELECT bc.company_name AS 公司名称, AVG(bbd.pay_sum) AS 日均营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL GROUP BY bc.company_name ORDER BY 公司名称;"
  },
  {
    "question": "统计2023年4月各公司营收总和，并列出排名前3的公司。",
    "sql": "SELECT bc.company_name AS 公司名称, SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL GROUP BY bc.company_name ORDER BY 总营收 DESC LIMIT 3;"
  },
  {
    "question": "查询2023年4月宜春分公司各服务区每日营收明细，并按日期排序。",
    "sql": "SELECT bbd.service_name AS 服务区名称, bbd.oper_date AS 日期, bbd.pay_sum AS 营收金额 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bc.company_name = '宜春分公司' AND bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL ORDER BY 日期;"
  },
  {
    "question": "对比2023年4月与2023年3月各公司总营收变化情况。",
    "sql": "WITH apr_data AS (SELECT bc.company_name AS 公司名称, SUM(bbd.pay_sum) AS 四月总营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL GROUP BY bc.company_name), mar_data AS (SELECT bc.company_name AS 公司名称, SUM(bbd.pay_sum) AS 三月总营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-03-01' AND '2023-03-31' AND bc.delete_ts IS NULL GROUP BY bc.company_name) SELECT apr_data.公司名称, apr_data.四月总营收, mar_data.三月总营收, apr_data.四月总营收 - mar_data.三月总营收 AS 差额 FROM apr_data JOIN mar_data ON apr_data.公司名称 = mar_data.公司名称;"
  },
  {
    "question": "查询2023年4月各公司日均营收排名前5的公司。",
    "sql": "SELECT bc.company_name AS 公司名称, AVG(bbd.pay_sum) AS 日均营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL GROUP BY bc.company_name ORDER BY 日均营收 DESC LIMIT 5;"
  },
  {
    "question": "统计2023年第一季度（1-3月）各公司的总营收并按公司排序。",
    "sql": "SELECT bc.company_name AS 公司名称, SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-01-01' AND '2023-03-31' AND bc.delete_ts IS NULL GROUP BY bc.company_name ORDER BY 公司名称;"
  },
  {
    "question": "查询2023年4月各公司营收金额最高的单日数据。",
    "sql": "SELECT bc.company_name AS 公司名称, MAX(bbd.pay_sum) AS 单日最高营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL GROUP BY bc.company_name ORDER BY 单日最高营收 DESC;"
  },
  {
    "question": "统计2023年4月各公司营收总金额，并计算其占总营收的比例。",
    "sql": "WITH total_revenue AS (SELECT SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL), company_revenue AS (SELECT bc.company_name AS 公司名称, SUM(bbd.pay_sum) AS 公司营收 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bc.delete_ts IS NULL GROUP BY bc.company_name) SELECT cr.公司名称, cr.公司营收, (cr.公司营收 / tr.总营收 * 100)::numeric(5,2) AS 占比百分比 FROM company_revenue cr, total_revenue tr;"
  },
  {
    "question": "查询2023年4月各公司中营收金额超过10万元的记录，并按金额降序排列。",
    "sql": "SELECT bc.company_name AS 公司名称, bbd.oper_date AS 日期, bbd.pay_sum AS 营收金额 FROM bss_service_area bsa JOIN bss_company bc ON bsa.company_id = bc.id JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bbd.pay_sum > 100000 AND bc.delete_ts IS NULL ORDER BY 营收金额 DESC;"
  },
  {
    "question": "分析2023年4月1日各路段的车流分布情况，找出车流高峰期的路段。",
    "sql": "SELECT sr.section_name AS 路段名称, cd.count_date AS 统计日期, SUM(cd.customer_count) AS 车流量 FROM bss_section_route sr JOIN bss_section_route_area_link link ON sr.id = link.section_route_id JOIN bss_car_day_count cd ON link.service_area_id = cd.service_area_id WHERE cd.delete_ts IS NULL AND cd.count_date = '2023-04-01' GROUP BY sr.section_name, cd.count_date ORDER BY 车流量 DESC LIMIT 10;"
  },
  {
    "question": "统计2023年4月1日不同车辆类型的车流量及其对应路段，分析哪种车辆对路段车流贡献最大。",
    "sql": "SELECT sr.section_name AS 路段名称, cd.car_type AS 车辆类型, SUM(cd.customer_count) AS 车流量 FROM bss_section_route sr JOIN bss_section_route_area_link link ON sr.id = link.section_route_id JOIN bss_car_day_count cd ON link.service_area_id = cd.service_area_id WHERE cd.delete_ts IS NULL AND cd.count_date = '2023-04-01' GROUP BY sr.section_name, cd.car_type ORDER BY 车流量 DESC LIMIT 10;"
  },
  {
    "question": "统计每个开放服务区的总营收金额，并按营收金额降序排列前10名。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '开放' AND bsa.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 总营收 DESC LIMIT 10;"
  },
  {
    "question": "统计每个关闭服务区的总营收金额，并按营收金额升序排列前10名。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '关闭' AND bsa.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 总营收 ASC LIMIT 10;"
  },
  {
    "question": "比较开放与关闭状态的服务区在2023年4月的平均每日营收。",
    "sql": "SELECT bsa.service_state AS 服务区状态, AVG(bbd.pay_sum) AS 平均每日营收 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bsa.delete_ts IS NULL GROUP BY bsa.service_state;"
  },
  {
    "question": "统计2023年4月每天所有服务区的总营收，并按日期升序排列。",
    "sql": "SELECT oper_date AS 统计日期, SUM(pay_sum) AS 总营收 FROM bss_business_day_data WHERE oper_date BETWEEN '2023-04-01' AND '2023-04-30' GROUP BY oper_date ORDER BY 统计日期 ASC;"
  },
  {
    "question": "找出2023年4月营收最高的3个开放服务区。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '开放' AND bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bsa.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 总营收 DESC LIMIT 3;"
  },
  {
    "question": "找出2023年4月营收最低的3个关闭服务区。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bbd.pay_sum) AS 总营收 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '关闭' AND bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bsa.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 总营收 ASC LIMIT 3;"
  },
  {
    "question": "统计2023年4月每天开放服务区的平均营收，并按日期升序排列。",
    "sql": "SELECT bbd.oper_date AS 统计日期, AVG(bbd.pay_sum) AS 平均营收 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '开放' AND bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bsa.delete_ts IS NULL GROUP BY bbd.oper_date ORDER BY 统计日期 ASC;"
  },
  {
    "question": "统计2023年4月每天关闭服务区的平均营收，并按日期升序排列。",
    "sql": "SELECT bbd.oper_date AS 统计日期, AVG(bbd.pay_sum) AS 平均营收 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '关闭' AND bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bsa.delete_ts IS NULL GROUP BY bbd.oper_date ORDER BY 统计日期 ASC;"
  },
  {
    "question": "统计2023年4月各开放服务区的订单总数，并按订单总数降序排列前10名。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bbd.order_sum) AS 订单总数 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '开放' AND bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bsa.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 订单总数 DESC LIMIT 10;"
  },
  {
    "question": "统计2023年4月各关闭服务区的订单总数，并按订单总数升序排列前10名。",
    "sql": "SELECT bsa.service_area_name AS 服务区名称, SUM(bbd.order_sum) AS 订单总数 FROM bss_service_area bsa JOIN bss_business_day_data bbd ON bsa.service_area_no = bbd.service_no WHERE bsa.service_state = '关闭' AND bbd.oper_date BETWEEN '2023-04-01' AND '2023-04-30' AND bsa.delete_ts IS NULL GROUP BY bsa.service_area_name ORDER BY 订单总数 ASC LIMIT 10;"
  }
]