我有一张桌子,我正在存储每个用户的出席情况。我有很多用户,我想返回每个用户最后两个记录。最近更新的记录
答案 0 :(得分:0)
WITH
sorted_att AS
(
SELECT
*,
ROW_NUMBER() OVER (PARTITION BY att_empID
ORDER BY att_ID DESC
)
AS att_emp_sequence_id
FROM
tblAttData
)
SELECT
*
FROM
sorted_att
WHERE
att_emp_sequence_id <= 2