查询一个表,把对应的行转列怎么写?

-一个大坑 -一个大坑 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

select t1.deriveno, t1.carno, t1.begintime, t2.endtime
from (select deriveno, carno, actualtime begintime
FROM (select a.deriveno,
a.carno,
a.stagecode,
to_char(a.actualtime, 'yyyy-mm-dd hh24:mi:ss') as actualtime
from app_carstatus a, app_send b
where a.deriveno = b.deriveno
and b.status in ('0', '10')
and b.deriveno not in (select deriveno from app_ridecost))
where stagecode = '3') t1
left join (select deriveno, actualtime endtime
from (select a.deriveno,
a.carno,
a.stagecode,
to_char(a.actualtime, 'yyyy-mm-dd hh24:mi:ss') as actualtime
from app_carstatus a, app_send b
where a.deriveno = b.deriveno
and b.status in ('0', '10')
and b.deriveno not in
(select deriveno from app_ridecost))
WHERE STAGECODE = '4') t2
on t1.deriveno = t2.deriveno

取3的查询,然后把对应的4行转列。但是我现在还有6.7也要行转列
...全文
评论 4
收藏 已收藏
分享
返回顶部