SQL怎么编写查询显示本月上机时间最短的前三名用户卡号

来源:百度知道 编辑:UC知道 时间:2024/09/18 03:48:33

与最长的一样啊
select top 3 cardid from tablename where MONTH(登录日期)=month(getdate()) group by cardid order by sum(时长)

select top 3 id from (select name,sum(时长) as 时长 from table_name where 月份=当前月 group by name order by 时长)