Molet

MYSQL中替换oracle中runum用法

Molet 批处理 2023-02-27 992浏览 0

一 、

SELECT
*
FROM
(SELECT
A.*,
rownum AS RN
FROM
(SELECT (@rownum := @rownum + 1) AS rownum, B.LL11,
B.KS01
FROM
TA_HISTORY B,(SELECT @rownum := 0) r
WHERE 1 = 1
AND B.KS01 > ‘2017-10-8 9:51’
AND B.KS01 < ‘2017-11-8 9:51’
ORDER BY B.KS01 DESC) A ) C
WHERE C.RN = 1

二、limit 用法

SELECT
*
FROM
(SELECT LL11,
KS01
FROM
TA_HISTORY
WHERE 1 = 1
AND KS01 > ‘2017-10-8 10:37’
AND KS01 < ‘2017-11-8 10:37’
ORDER BY KS01 DESC) A
LIMIT 0, 1

 

继续浏览有关 数据库技术文章/教程 的文章
发表评论