求一条sql语句,把图一转换成图二。
2个回答
展开全部
select cpname
,max(decode(rvl,1,PEJIAN) )as PEJIAN1
,max(decode(rvl,2,PEJIAN) )as PEJIAN2
,max(decode(rvl,3,PEJIAN) )as PEJIAN3
,max(decode(rvl,4,PEJIAN) )as PEJIAN4
from
(
select cpname,PEJIAN,id
,rank() over(partition by cpname order by id) as rvl
from test_a
)
group by cpname
--将扮渗哗test_a换喊返成你的厅行table就可以了
,max(decode(rvl,1,PEJIAN) )as PEJIAN1
,max(decode(rvl,2,PEJIAN) )as PEJIAN2
,max(decode(rvl,3,PEJIAN) )as PEJIAN3
,max(decode(rvl,4,PEJIAN) )as PEJIAN4
from
(
select cpname,PEJIAN,id
,rank() over(partition by cpname order by id) as rvl
from test_a
)
group by cpname
--将扮渗哗test_a换喊返成你的厅行table就可以了
追问
select cpname,PEJIAN,id
,rank() over(partition by cpname order by id) as rvl
这句出错!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询