sql oracle新临时列
我的SQL输出如下所示:sql oracle新临时列,sql,oracle,Sql,Oracle,我的SQL输出如下所示: column1 50 20 30 我的最终结果应该是: column1 column1_temp #1 50 50% #2 20 20% #3 30 30% 文本中应该发生什么: SQL SUM(column1 #1-#3) = 100 (or what ever comes out as result) which is 100% | column1 #1 50 from 100 is 50%
column1
50
20
30
我的最终结果应该是:
column1 column1_temp
#1 50 50%
#2 20 20%
#3 30 30%
文本中应该发生什么:
SQL SUM(column1 #1-#3) = 100 (or what ever comes out as result) which is
100% | column1 #1 50 from 100 is 50%
column1 #2 20 from 100 is 20%
column1 #3 30 from 100 is 30%
您可能想使用
to_char()
和/或round()
来获得所需的格式,但上面应该给出原始数字。选择column1,CONCAT(column1,“%”)作为t中的“column1_copy”
?您使用MySQL的数据库是什么,SQL或Oracle,因为您用quetion的标题和Oracle的标记把我弄糊涂了-很抱歉让您弄糊涂了您试过@danihp的SQL代码片段吗?除非你能提供更多关于你想要什么的信息,否则这应该会给你你看起来需要的东西。请检查,假设这是你的问题(原文编辑另有明确说明)。
select column1,
(column1 / sum(column1) over ()) * 100 as pct
from the_table