论坛首页 综合技术论坛

SLQ分组查询最大

浏览 2178 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-07-27  

查询分组中最大值所在列的所有字段例子:

 

查询所有用户最后一次登录的详细信息

 

select 
	* 
from 
	aips.user_login_history 
where 
	(userid,logintime) 
		in (select userid,max(logintime) from aips.user_login_history group by userid)
 

 

论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics