我有个另类的方法- -
select count(*)+1 from tb where time<(select max(time) from tb where num=8)
查num=8的数据在tb表中第几行
oracle中有rownum,但是mysql中没有rownum,需要定义变量实现
SELECT
tt.create_by_name ,@rownum :=@rownum + 1 AS rownum
FROM
(
SELECT
t.create_by_name ,@rownum := 0
FROM
gxr_170731 t
ORDER BY
t.create_by_name
LIMIT 0,
20
) tt