sql问题,以获得最高价值明显

时间:2022-06-21 13:16:50

I have one table take for example test in oracle database

我有一个表在oracle数据库中进行测试

test has two column Column 1 has below value

测试有两列第1列具有低于值

15.1
15.2
15.3
14.1
14.2
13.1
13.5
10.1
10.5

and column two has various name value Kunal , Mangesh.. etc.

第二列有各种名称价值Kunal,Mangesh等。

Now through sql query i want to take distinct value of column one and highest value per integer wise means

现在通过sql查询我想采取第一列的不同值和每个整数的最高值意味着

13.5
10.5
15.3 // ect. 

And its row also means I want highest value of column one number of distinct integer up to decimal value

它的行也意味着我想要第一列不同整数到十进制值的最高值

1 个解决方案

#1


2  

To start with: If I understand correctly, the second column with the name doesn't have anything to do with your question.

首先:如果我理解正确,带有名称的第二列与您的问题没有任何关系。

It seems you want to get the highest number per integer part. So one result row per TRUNC(col1) (or FLOOR(col1) maybe). Use GROUP BY for this. Then you want the maximum value, which is MAX(col1) of course.

看来你想获得每个整数部分的最高数字。因此,每个TRUNC(col1)(或FLOOR(col1))可能有一个结果行。为此使用GROUP BY。那么你想要最大值,当然是MAX(col1)。

select max(col1)
from mytable
group by trunc(col1)
order by trunc(col1);

#1


2  

To start with: If I understand correctly, the second column with the name doesn't have anything to do with your question.

首先:如果我理解正确,带有名称的第二列与您的问题没有任何关系。

It seems you want to get the highest number per integer part. So one result row per TRUNC(col1) (or FLOOR(col1) maybe). Use GROUP BY for this. Then you want the maximum value, which is MAX(col1) of course.

看来你想获得每个整数部分的最高数字。因此,每个TRUNC(col1)(或FLOOR(col1))可能有一个结果行。为此使用GROUP BY。那么你想要最大值,当然是MAX(col1)。

select max(col1)
from mytable
group by trunc(col1)
order by trunc(col1);