当前位置:Gxlcms > mysql > SQLSERVER中FIRST_VALUE和LAST_VALUE

SQLSERVER中FIRST_VALUE和LAST_VALUE

时间:2021-07-01 10:21:17 帮助过:22人阅读

WITH test as ( select '乐可乐可的部落格' as name,10 as score UNION ALL select '乐可乐可的部落格',15 UNION ALL select '乐可乐可的部落格',20 UNION ALL select '微软认证',30 UNION ALL select '微软认证',40 UNION ALL select '微软认证',40 ) selec

WITH test

as

(

select '乐可乐可的部落格' as name,10 as score

UNION ALL

select '乐可乐可的部落格',15

UNION ALL

select '乐可乐可的部落格',20

UNION ALL

select '微软认证',30

UNION ALL

select '微软认证',40

UNION ALL

select '微软认证',40

)

select name,score

,FIRST_VALUE(score)over(order by name) as fst

,LAST_VALUE(score)over(order by name) as Lst

from test

人气教程排行