V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  wenxueywx  ›  全部回复第 4 页 / 共 4 页
回复总数  65
1  2  3  4  
@hsfzxjy 确实;十几年又一代人了,按现在生育率趋势看压力很大
简单地,按照各地人才引进政策来看,学历本科(不包含)以上。
@AoEiuV020JP 人才的分界线越来越高👍。
2023-03-29 11:29:30 +08:00
回复了 godleon 创建的主题 程序员 请教一个数据处理的需求,寻一个高效率的解决方法?
@godleon 特意用 mysql8.0 试了下纯 sql 的方法
CREATE TABLE `t01` (
`id` int NOT NULL AUTO_INCREMENT,
`type` int DEFAULT NULL,
`value` double DEFAULT NULL,
`date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB ;

INSERT INTO `t01` VALUES (1,1,10.111,'2023-03-21 01:00:00'),(2,2,19.111,'2023-03-21 01:00:00'),(3,2,11.111,'2023-03-21 02:00:00'),(4,3,12.111,'2023-03-21 02:00:00'),(5,1,13.111,'2023-03-22 11:00:00'),(6,1,14.111,'2023-03-22 12:00:00'),(7,1,15.111,'2023-03-23 12:00:00');

select distinct date(`date`) as`date`,`type`,count(*) over(partition by date(`date`),`type`) as count, first_value(`date`) over (partition by date(`date`),`type` order by `date` desc) as `latest_datetime`,first_value(`value`) over (partition by date(`date`),`type` order by `date` desc) as `latest_value` from t01;
+------------+------+-------+---------------------+--------------+
| date | type | count | latest_datetime | latest_value |
+------------+------+-------+---------------------+--------------+
| 2023-03-21 | 1 | 1 | 2023-03-21 01:00:00 | 10.111 |
| 2023-03-21 | 2 | 2 | 2023-03-21 02:00:00 | 11.111 |
| 2023-03-21 | 3 | 1 | 2023-03-21 02:00:00 | 12.111 |
| 2023-03-22 | 1 | 2 | 2023-03-22 12:00:00 | 14.111 |
| 2023-03-23 | 1 | 1 | 2023-03-23 12:00:00 | 15.111 |
+------------+------+-------+---------------------+--------------+
2023-03-28 17:08:54 +08:00
回复了 godleon 创建的主题 程序员 请教一个数据处理的需求,寻一个高效率的解决方法?
期望的数据有问题吧,3-22 的 type 为 1 的数据有两条。如果确认的话窗口函数确实可以解决
1  2  3  4  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5321 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 20ms · UTC 06:25 · PVG 14:25 · LAX 23:25 · JFK 02:25
Developed with CodeLauncher
♥ Do have faith in what you're doing.