[英]what is the correct way to select the highest value from column not primary key
I have a table (report) consist of several records and one of them about int values (column) I am trying to get the highest number of the fall_value column the id only primary key, the table as following:我有一个表(报告)由几条记录组成,其中一条是关于 int 值(列)我试图获得 fall_value 列的最高编号,id 唯一的主键,表如下:
id (P)编号 (P) | fall_value下降值 | date日期 |
---|---|---|
3 3个 | 1.2 1.2 | 2021-01-29 2021-01-29 |
4 4个 | 1.5 1.5 | 2021-01-30 2021-01-30 |
5 5个 | 1.6 1.6 | 2021-01-30 2021-01-30 |
6 6个 | 1 1个 | 2021-01-31 2021-01-31 |
7 7 | 5 5个 | 2021-01-31 2021-01-31 |
8 8个 | 1.5 1.5 | 2021-01-31 2021-01-31 |
9 9 | 1.5 1.5 | 2021-01-31 2021-01-31 |
10 10 | 14 14 | 2021-01-31 2021-01-31 |
11 11 | 15 15 | 2021-01-31 2021-01-31 |
expected result: 15预期结果: 15
I have tried the following inquiry:我尝试了以下查询:
SELECT max(fall_value) from report;
I got an unexpected result: 5我得到了意想不到的结果: 5
and also I got a message saying:我还收到一条消息说:
Current selection does not contain a unique column.当前选择不包含唯一列。 Grid edit, checkbox, Edit, Copy and Delete features are not available网格编辑、复选框、编辑、复制和删除功能不可用
It sounds like fall_value
is a string, not a number, and the string "5" is indeed greater than the string "15".听起来fall_value
是一个字符串,而不是一个数字,字符串“5”确实大于字符串“15”。
Try converting to a number.尝试转换为数字。 A convenient way is to use implicit conversion:一种方便的方法是使用隐式转换:
SELECT max(fall_value + 0)
FROM report;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.