SELECT * from (
SELECT t1.DisplayName,t.UserId,t.OrderId,t.FillMoneyAgent,t.GoodsName,t.GoodsDescription,t.ResponseMoney,t.ResponseTime,ROW_NUMBER() over(partition by CONVERT(VARCHAR(10), t.ResponseTime, 120),t.UserId order by t.ResponseTime ) as RankNum ,count(t.OrderId) over(partition by CONVERT(VARCHAR(10), t.ResponseTime, 120),t.UserId order by CONVERT(VARCHAR(10), t.ResponseTime, 120 ) ) as RankNum2
FROM C_FillMoney t,
C_User_Register t1
WHERE t.ResponseTime >= '2024-01-01'
AND t.ResponseTime <= '2024-01-15'
AND t.Status = '1'
AND t.UserId = t1.UserId
) as b where RankNum<=2 and RankNum2>=2
--and RankNum2=1
order by b.ResponseTime
offset (0*100) rows
fetch next 100 rows only;
标签:10,CONVERT,VARCHAR,UserId,明细,120,ResponseTime,SQL,Sever From: https://blog.51cto.com/jition/9319516