select 来自列而非主键的最大值的正确方法是什么
what is the correct way to select the highest value from column not primary key
我有一个 table(报告)由几条记录组成,其中一条关于 int 值(列)键,table如下:
id (P)
fall_value
date
3
1.2
2021-01-29
4
1.5
2021-01-30
5
1.6
2021-01-30
6
1
2021-01-31
7
5
2021-01-31
8
1.5
2021-01-31
9
1.5
2021-01-31
10
14
2021-01-31
11
15
2021-01-31
预期结果:15
我试过以下查询:
SELECT max(fall_value) from report;
我得到了意想不到的结果:5
我还收到一条消息说:
Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available
听起来fall_value
是字符串,不是数字,字符串“5”确实大于字符串“15”。
尝试转换为数字。一种方便的方法是使用隐式转换:
SELECT max(fall_value + 0)
FROM report;
我有一个 table(报告)由几条记录组成,其中一条关于 int 值(列)键,table如下:
id (P) | fall_value | date |
---|---|---|
3 | 1.2 | 2021-01-29 |
4 | 1.5 | 2021-01-30 |
5 | 1.6 | 2021-01-30 |
6 | 1 | 2021-01-31 |
7 | 5 | 2021-01-31 |
8 | 1.5 | 2021-01-31 |
9 | 1.5 | 2021-01-31 |
10 | 14 | 2021-01-31 |
11 | 15 | 2021-01-31 |
预期结果:15
我试过以下查询:
SELECT max(fall_value) from report;
我得到了意想不到的结果:5
我还收到一条消息说:
Current selection does not contain a unique column. Grid edit, checkbox, Edit, Copy and Delete features are not available
听起来fall_value
是字符串,不是数字,字符串“5”确实大于字符串“15”。
尝试转换为数字。一种方便的方法是使用隐式转换:
SELECT max(fall_value + 0)
FROM report;