简体   繁体   English

SQL用MAX值替换列

[英]SQL Replace column with MAX value

In Oracle SQL how can a get a table replacing a column's value with the MAX? 在Oracle SQL中,如何获得一个用MAX替换列值的表?

I have: 我有:

ID      Val
======= =======
1       10
2       19
3       55
4       40

And I want: 而且我要:

ID      Val
======= =======
1       55
2       55
3       55
4       55

I tried: 我试过了:

SELECT    id, MAX(Val)
FROM      table;

But it's complaining about the GROUP BY , if I add it for id it will return the original table. 但是它在抱怨GROUP BY ,如果我为id添加它,它将返回原始表。

Use a window function: 使用窗口功能:

SELECT id, MAX(Val) OVER ()
FROM table;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM