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

更多相关文章

  1. PLSQL乱码解决方案
  2. 数据库不支持中文解决方案(mysql)
  3. Mysql替代解决方案Cassandra
  4. [置顶] Android屏幕适配解决方案
  5. 物流货运移动APP解决方案
  6. 转:Android Studio Error:Connection timed out: connect.解决方
  7. android.os.NetworkOnMainThreadException的解决方案
  8. Android极光推送jPush混淆解决方案终极篇
  9. 【Android开发学习39】VideoView在GLSurfaceView之上显示的解决

随机推荐

  1. 裸辞,杀回一线!
  2. Ansible 之 自动化部署redis主从(单机)
  3. 小鹿又熬肝写了一份 Vue 2.0 核心原理!
  4. 《Python知识手册》更新V2.2版,添加 Plotl
  5. TensorFlow 实战多元线性回归问题
  6. 小鹿 | 谈谈我的三观!
  7. 深度学习中几种常用框架的介绍
  8. 零基础学习Python列表操作
  9. 这么用 if-else,小鹿差点被辞退!
  10. centos 用户权限管理与文件权限设定 详