wenxueywx 最近的时间轴更新
wenxueywx

wenxueywx

V2EX 第 583288 号会员,加入于 2022-05-30 11:35:10 +08:00
wenxueywx 最近回复了
@hjw45611 人才和人口是两个问题;人才层次从低到高应该是一个三角形分布;现在三角形的腰部过大,顶部太小;
@Aloento 哎,怎么说呢,我认为现在的学历水分还是比较大的。
@FranzKafka95 嗯,就像一个一边放水一边注水的水池;只不过目前注水速度还是增加的
@hsfzxjy 确实;十几年又一代人了,按现在生育率趋势看压力很大
简单地,按照各地人才引进政策来看,学历本科(不包含)以上。
@AoEiuV020JP 人才的分界线越来越高👍。
@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 |
+------------+------+-------+---------------------+--------------+
期望的数据有问题吧,3-22 的 type 为 1 的数据有两条。如果确认的话窗口函数确实可以解决
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   718 人在线   最高记录 6067   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 21:22 · PVG 05:22 · LAX 14:22 · JFK 17:22
Developed with CodeLauncher
♥ Do have faith in what you're doing.