微信扫码
与创始人交个朋友
我要投稿
-- 订单表 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-12-22
告别加班!这款 AI 数据神器,让你像聊天一样轻松搞定数据!
2024-12-21
全网最全ChatGPT财务分析提示词解决方案
2024-12-21
万字长文梳理基于LLM的Text-to-SQL发展进程
2024-12-20
从0到1解构数据问答系统架构:三层模型全解析
2024-12-19
博士眼镜 × 观远数据 × 飞书 | AI 和 BI 赋能业务实践
2024-12-19
传统水务如何借助AI完成智能化升级?一文看懂核心架构与实战应用!
2024-12-18
ChatBl有什么用,看这篇就够了!
2024-12-18
在Windows上使用RAGFlow+Ollama+Qwen2.5,搭建医疗问诊助手(附相关数据集和案例)
2024-06-20
2024-06-14
2024-07-03
2024-06-06
2024-06-14
2024-06-21
2024-06-16
2024-06-07
2024-07-24
2024-10-09
2024-12-13
2024-11-19
2024-11-06
2024-10-25
2024-10-25
2024-10-25
2024-10-18
2024-10-09