TSQL - 非标准化表上的最大值或最高日期
16lz
2021-01-22
I have the following table:
我有下表:
Table: UserName
表:UserName
Userid User UserUpdate
1 Dan 1/1/2005
1 Dan 1/1/2007
1 Dan 1/1/2009
2 Pam 1/1/2005
2 Pam 1/1/2006
2 Pam 1/1/2008
3 Sam 1/1/2008
3 Sam 1/1/2009
I need to extract the latest updated for all these users, basically here's what I'm looking for:
我需要为所有这些用户提取最新更新,基本上这是我正在寻找的:
Userid User UserUpdate
1 Dan 1/1/2009
2 Pam 1/1/2008
3 Sam 1/1/2009
I've tried doing a SELECT TOP or Max but get only the latest result, i.e. 1 result for the WHOLE table, which is not what I want.
我尝试过做一个SELECT TOP或Max但只得到最新的结果,即WHOLE表的1个结果,这不是我想要的。
3 个解决方案
#1
4
SELECT Userid, User, Max(UserUpdate) AS MaxDate
FROM myTable
GROUP BY Userid, User
更多相关文章
- PLSQL乱码解决方案
- 数据库不支持中文解决方案(mysql)
- Mysql替代解决方案Cassandra
- [置顶] Android屏幕适配解决方案
- 物流货运移动APP解决方案
- 转:Android Studio Error:Connection timed out: connect.解决方
- android.os.NetworkOnMainThreadException的解决方案
- Android极光推送jPush混淆解决方案终极篇
- 【Android开发学习39】VideoView在GLSurfaceView之上显示的解决