![](/img/trans.png)
[英]Select Rows With the Greatest Value In One Column When Another Column Has matching Values
[英]Oracle SQL to compare column values and select rows there greatest value is in column 1
我想弄清楚如何從 column1 值最大的表中使用 sql 到 select 行? 換句話說,假設我有一個包含 10 列的表 Table1。 我需要將 column1 與 column2 和 column3 以及 column4 和 column5 以及 select 進行比較,其中 column1 具有最大值。 比如下面是我的表格,這個例子中column1的值最大。
column1 column2 column3 column4 column5 column6 column7 column8
299 2 56 8 16 9 18 33
使用greatest()
:
where column1 > greatest(column2, column3, column4, column5, column6, column7, column8)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.