问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

Oracle的SQL中如何将动态生成的列进行相加 要TEU=20GP+2*(40GP+40HC)

发布网友 发布时间:2022-04-23 00:57

我来回答

4个回答

热心网友 时间:2023-10-09 15:58

如果需要保留20GP等,那么再加一层即可:

select a.*, "20GP" + 2*("40GP" + "40HC") as TEU
from (
SELECT PORT.CNAME AS PORTLOAD,
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '20' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) ) AS "20GP",
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) ) AS "40GP",
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'HC' and bo.boid = bkctn.boid(+) ) AS "40HC",
BO.ETD,
BO.VOY,
FROM BO,PORT
WHERE BO.PORTLOAD=PORT.PORT
) a

如果不需要保留,直接相加:
SELECT PORT.CNAME AS PORTLOAD,
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '20' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) )
+ 2*( (select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) ) + (select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'HC' and bo.boid = bkctn.boid(+) ) ) AS TEU,
BO.ETD,
BO.VOY,
FROM BO,PORT
WHERE BO.PORTLOAD=PORT.PORT

热心网友 时间:2023-10-09 15:58

select a.*,"20GP"+2*("40GP"+"40HC") TEU
(SELECT PORT.CNAME AS PORTLOAD,
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '20' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) ) AS "20GP",
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) ) AS "40GP",
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'HC' and bo.boid = bkctn.boid(+) ) AS "40HC",
BO.ETD,
BO.VOY,
FROM BO,PORT
WHERE BO.PORTLOAD=PORT.PORT
) a追问还是不行

热心网友 时间:2023-10-09 15:59

SELECT PORTLOAD,20GP+2*(40GP+40HC) AS TEU FROM (SELECT PORT.CNAME AS PORTLOAD,
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '20' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) ) AS "20GP",
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'GP' and bo.boid = bkctn.boid(+) ) AS "40GP",
(select BKCTN.PNUM
from bkctn
where CTNSIZE = '40' AND CTNTYPE = 'HC' and bo.boid = bkctn.boid(+) ) AS "40HC",
BO.ETD,
BO.VOY,
FROM BO,PORT
WHERE BO.PORTLOAD=PORT.PORT)

热心网友 时间:2023-10-09 15:59

select 20GP+2*(40GP+40HC) from al
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
八月中国最凉快的地方 八月份哪里最凉快,去哪旅游好?美丽的地方 乱字同韵字是什么意思 华硕笔记本电脑触摸板怎么开笔记本电脑触摸板怎么开启和关闭_百度知 ... 陕西职务侵占案立案准则 结婚后我的恋情维系了十年,怎么做到的? 玉米仁子饭产自哪里 中国期货交易所的交易品种有哪些? 历史要怎么读,有啥诀窍 高中历史诀窍 可以教我抖音怎么去掉抖音号吗?谢谢 苹果6港版能用电信卡吗 港行iphone6能用4g电信卡吗 iphone6港版不支持电信怎么办 港版iphone6 plus插上卡后显示中国电信是不是代表支持中国电信 港版iphone6 MG492ZP/A支持电信卡吗 港版苹果6型号MG4J2ZP/A支持电信卡吗? 港行iphone6三网能用电信吗? 关于港版iphone6能否用电信卡本人已解决 港币iPhone6 可以用电信的卡吗 iPhone6港版可以用电信卡吗 OPPO Reno5k首次充电需要八小时么还是充满就拔下来? 怎么涂指甲油不会弄到手上? 苦瓜籽粉生吃还是炒熟再吃 指甲油倒在手上,衣服上怎么洗掉? 把指甲油涂手上了怎么办? 苦瓜可以生吃 那么苦瓜里面的子要不要生吃 吃了有没有好处 指甲油弄到手上了、怎么洗掉? 苦瓜可以生吃吗?生吃有什么功效? 苦瓜的瓤和籽能吃吗? 物流方面的英文缩写 什么叫加壳?怎么样加壳? "以货柜为单位"如何翻译呢? 天津的酒吧一条街在那块啊?有哪家酒吧不错,推荐一下! 看音标写单词 海运知识 English questions "伴奏"用英文怎么说 翻译这段葡萄牙语 拜托啦……(^人^) 怎样能快速的背出英语单词? 外贸中OC是什么意思 英语高手帮翻译一下 求翻译船公司公告 葡萄牙国歌的国歌歌词 巴西国歌叫啥? 请哪位高手为我翻译下面的英文,急用!!!非常感谢!!! 江南style歌词 请帮忙翻译以下韩文奖项~~ 求翻译牛人!!! 碧波尔天然气热水器TsO24一12H7,显示正常,不点火