-- code字段值:例如 测试2022090001
-- LENGTH ( t.code) - 4 获取排序部分的数字长度
-- SUBSTRING ( t.code, LENGTH ( t.code) - 4 ) 获取排序部分的数字 如:0001
SELECT
t.*
FROM
t_test t
WHERE
1 = 1
AND t.code LIKE concat ( '%', '202209', '%' )
ORDER BY
SUBSTRING ( t.code, LENGTH ( t.code) - 4 ) DESC;
02-15
6924
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-01
3310
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-30
6673
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)