微信扫码
添加专属顾问
我要投稿
-- 订单表 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+中大型企业
2025-04-04
OpenCSG AutoHub v0.4.2 版本发布 - 智能自动化再度升级!
2025-04-03
万字长文详解Text-to-SQL
2025-04-01
了解 AI 驱动的 DevOps「四大优势」,全方位赋能开发者
2025-04-01
DeepSeek在数据领域的100个应用场景
2025-03-30
下一代企业IT架构:MCP中台和软件进化
2025-03-30
ES × BM25:打造高效文档检索的秘密
2025-03-28
RagFlow进阶|Text2SQL 优化方法明细大公开
2025-03-28
DeepSeek+Power BI实现滚动表格效果SVG
2024-10-14
2024-06-20
2025-02-04
2024-10-09
2024-06-14
2024-06-16
2024-06-14
2024-05-31
2024-07-24
2025-02-09
2025-03-24
2025-03-11
2025-03-10
2025-03-10
2025-02-28
2025-02-25
2025-02-22
2025-02-22