sql - 如何在 MS Access SQL 上选择最多两列并按站分组
问题描述
我有一个像这样的简单表
station num tim
-------------------------
1 150 10
1 200 222
1 100 5000
1 200 555
2 100 500
2 120 200
3 1 2
所需的输出是这样的:
station num tim
---------------------
1 200 555
2 120 200
3 1 2
但我不能使用ROW_NUMBER()
,因为查询需要在 MS Access SQL 中执行。
谁能帮我?
解决方案
你也可以试试这个:
select t2.station,t1.num as num,max(t2.tim) tim from (select max(num) num
from tablename group by station) t1
join tablename on t1.num = t2.num group by t1.num,t2.station
推荐阅读
- android - 为 android 绘制带有图层列表的图像
- webgl - 浏览器绘制时间之外的 WebGL 渲染
- python - 有没有办法检测 Pandas 中分类变量的变化?
- javascript - 赛普拉斯输入错误 - textarea 中的输入混乱
- python - 将三个数据帧与匹配的时间戳和持续时间匹配相结合
- swift - 从另一个类 Swift 访问 navigationItem.title
- android-recyclerview - Recycler View 物品装饰没有获得焦点并且Talkback没有宣布它
- linux - 在 hdfs 路径中创建目录
- go - 动态 JSON 解码
- html - 为所有屏幕尺寸定位半圆