SELECT
IF
(
@o = user_id
AND @p = module_id,
CASE
WHEN @s != t.DT_CREATE THEN
@r := @r + 1 ELSE @r
END,
@r := 1
) AS fff,
@o := user_id,
@p := module_id,
@s := dt_create
FROM
dbscale.tb_user_exercise_record t,(
SELECT
@p := NULL,
@o = NULL,
@s = NULL,
@r = 1
) a
ORDER BY
user_id,
module_id,
dt_create DESC
类似rownumber over partition by,第一次失效,第二次才行,来个万能的大佬,或者操作过的大佬讲下