资讯动态

SQLite 实战:用 SQL 做数据统计,几分钟搞定原本几小时的数据处理

发布时间:2026/9/11 17:34:11 来源:尧图企业网站定制
create or replace view xx as 创建或覆盖 ADS 数据库下名为 xx 的视图。 select DATE_FORMAT(create_time, %Y-%m) AS month, 将项目的开始时间格式化为 年-月 的形式如 2026-08并将列名命名为 month count(1) as new, 计算该月份下的总记录数作为“新建”项目的数量 count(case when flow_node_id 5 then 1 end) as complete, 统计节点名称为待分析或节点 ID 为 5的记录作为“完成”项目数 count(case when flow_node_name PROJECT_ANALYZE_WAITING) or flow_node_id 4 then 1 end) as ai_recognition 统计节点名称为待分析或节点 ID 为 4 的记录作为“AI识别”项目数 from (需要统计的表名) 指定查询的数据来源为主项目表 (需要统计的表名) where deleted 0 过滤掉已被软删除的数据仅保留有效记录 group by DATE_FORMAT(create_time, %Y_%m) 按照月份进行分组汇总 order by month ASC; 将汇总后的结果按照月份从早到晚升序排列具体SQL代码--趋势统计 create or replace view xx as select DATE_FORMAT(create_time, %Y-%m) AS month, count(1) as new, count(case when flow_node_id 5 then 1 end) as complete, count(case when flow_node_name PROJECT_ANALYZE_WAITING) or flow_node_id 4 then 1 end) as ai_recognition from 表名 where deleted 0 group by DATE_FORMAT(create_time, %Y_%m) order by month ASC;

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价