+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| id | user_email | cat_id | sub_cat_id | score | out_of | score_in_per | date | groupId | groupType |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| 13 | [email protected] | 9 | 11 | 40 | 40 | 100 | 22-04-2017 | 34 | institute |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| 14 | [email protected] | 9 | 11 | 37 | 40 | 92.5 | 22-04-2017 | 34 | institute |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| 15 | [email protected] | 9 | 11 | 35 | 54 | 90.35 | 22-04-2017 | 34 | institute |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| 17 | [email protected] | 9 | 11 | 75 | 41 | 91.52 | 22-04-2017 | 34 | institute |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| 20 | [email protected] | 9 | 11 | 47 | 56 | 85 | 22-04-2017 | 34 | institute |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| 35 | [email protected] | 9 | 11 | 14 | 89 | 20.45 | 22-04-2017 | 34 | institute |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
| 37 | [email protected] | 9 | 11 | 69 | 78 | 45.45 | 22-04-2017 | 34 | institute |
+----+-------------------------+--------+------------+-------+--------+--------------+------------+---------+-----------+
从上面的表,我想获得最大的score_in_per
值作为一个子查询,但由于小数它不被工作降序或max(score_in_per)
凭什么妮获得最大score_in_per
如何使用子查询得到msyql表中的最大列值当值是十进制和非小数
这是我已经试过,但最大值不来..
(SELECT MAX(score_in_per)
FROM tbl_student_skill_score WHERE cat_id=9
and sub_cat_id=11
ORDER BY score_in_per DESC) as maxPortaScore
似乎问题是'ORDER BY score_in_per DESC',而不是'MAX'。 MAX有什么用?或者,也许问题是与外部查询?请也表明一下。 –