56,679
社区成员
发帖
与我相关
我的任务
分享
SELECT T.*
FROM
(
SELECT t1.*,
(
SELECT COUNT(*)+1 FROM tbl
WHERE dt<t1.dt AND YEAR(dt)=YEAR(t1.dt)
) AS g_id
FROM tbl t1
) T
WHERE T.g_id<=10
ORDER BY dt
Select * From T1 A join (
Select year(transtime) as Year1,
SUBSTRING_INDEX(cast(group_concat(Transtime) as char),',',10) as str
from (
Select * from t1 order by transtime)T group by year(TransTime))H
on year(A.transtime)=H.year1 and
INSTR(H.str,A.Transtime)<>0