SELECT * FROM
(SELECT *, ROW_NUMBER() OVER(ORDER BY id) as r FROM t1)
WHERE r BETWEEN 1 AND 5
ORDER BY id
需要显示第m到第n条,只需替换BETWEEN和AND后面的数即可。
前5次,应该是按时间排序,不区分打卡地点,对吧?!使用OLAP函数就能解决问题啦:
select * from (
select
(row_number() over (partition by 用户ID order by 打卡时间 asc)) AS row_id
用户ID,
打卡地点ID,
打卡时间
from table_name) t
where row_id<=5
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)