微信扫码
与创始人交个朋友
我要投稿
-- 订单表 CREATE TABLE orders ( order_id INT PRIMARY KEY, product_name VARCHAR(255), order_date DATE, quantity INT );
SELECT SUM(quantity) AS total_orders FROM orders WHERE product_name = 'xx产品' AND order_date >= CURDATE() - INTERVAL 7 DAY;
SELECT SUM(quantity) AS total_sales FROM orders WHERE product_name = 'xx产品' AND YEAR(order_date) = YEAR(CURDATE());
-- 国内销售表 CREATE TABLE domestic_sales ( product_name VARCHAR(255), sales_count INT ); -- 国外销售表 CREATE TABLE international_sales ( product_name VARCHAR(255), sales_count INT );
SELECT SUM(ds.sales_count) AS domestic_sales, SUM(is.sales_count) AS international_sales FROM domestic_sales ds, international_sales is WHERE ds.product_name = 'xx品牌' AND is.product_name = 'xx品牌';
WITH sales_data AS ( SELECT product_name, SUM(quantity) AS total_sales FROM orders WHERE product_name = 'xx品牌' AND order_date >= CURDATE() - INTERVAL 3 MONTH GROUP BY product_name ), ranked_sales AS ( SELECT product_name, total_sales, RANK() OVER (ORDER BY total_sales DESC) AS sales_rank FROM sales_data ) SELECT product_name, total_sales / 3 AS avg_monthly_sales FROM ranked_sales WHERE sales_rank = 1;
-- 假设有一张效率表CREATE TABLE efficiency ( region VARCHAR(255), product_name VARCHAR(255), efficiency_value DECIMAL(10,2), month DATE ); -- 查询效率环比下降的原因WITH current_month AS ( SELECT efficiency_value FROM efficiency WHERE region = '华北' AND product_name = 'xx' AND month = CURDATE() - INTERVAL 1 MONTH ), previous_month AS ( SELECT efficiency_value FROM efficiency WHERE region = '华北' AND product_name = 'xx' AND month = CURDATE() - INTERVAL 2 MONTH ) SELECT cm.efficiency_value - pm.efficiency_value AS efficiency_drop FROM current_month cm, previous_month pm;
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-06-20
2024-07-03
2024-06-14
2024-06-06
2024-06-14
2024-06-21
2024-06-16
2024-06-07
2024-07-21
2024-07-01