如下的功能,SQL将如何实现(考虑效率)?

OK_boom 2001-11-21 11:07:24
table a:
namecd seq time
======= ==== ========
no1 a 1200
no1 b 1700
no1 c 2030
no1 d 0350
no1 e 0830
no1 f 1200
index namecd+seq+time is unique .

table b:
namecd char(8)
ami char(4) null
amo char(4) null
pmi char(4) null
pmo char(4) null
oti char(4) null
oto char(4) null
...

现要将table a上的 1200, 1700,2030,0350,0830,1200六条记录横向填入ami,amo,
pmi,pmo,oti,oto 该怎么做?
...全文
61 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tommy Chang 2001-11-24
  • 打赏
  • 举报
回复
行列交换,用临时表可能好点。数据库开发版也许有高手提供高效的办法吧。

:)
linhu 2001-11-22
  • 打赏
  • 举报
回复
试试这个:
insert into b (ami , amo , pmi , pmo , oti , oto)
select ami = (select time from a where namecd = 'no1' and seq = 'a'),
amo = (select time from a where namecd = 'no1' and seq = 'b'),
.....

7,388

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 数据仓库
社区管理员
  • 数据仓库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧