我有以下表格:MySQL我如何只顯示以下查詢的最大值/最大值?
mysql> select * from F_FINDINGS;
+---------+------------+
| F_ID | CONFIDENCE |
+---------+------------+
| 1 | 100 |
| 2 | 70 |
| 2 | 0.35 |
| 1 | 100 |
+---------+------------+
mysql> select * from F_THINGS;
+---------+-------------------+--------+------------+
| F_ID | F_TITLE | S_ID | F_VALUE |
+---------+-------------------+--------+------------+
| 1 | STUFF A | 1 | 1.1 |
| 2 | STUFF C | 1 | 202.2 |
| 3 | OBJECT P | 1 | 10.7 |
| 4 | Things X | 2 | 540 |
| 5 | STUFF D | 2 | 1080 |
| 6 | OBJECT M | 2 | 455 |
| 7 | Things A | 3 | 333 |
| 8 | Things B | 4 | 825 |
| 9 | STUFF A | 1 | 103.4 |
| 10 | STUFF A | 1 | 98.4 |
+---------+-------------------+--------+------------+
mysql> select * from DUMP;
+--------+----------+
| D_ID | D_NAME |
+--------+----------+
| 1 | E0 |
| 2 | A1 |
| 3 | AB |
+--------+----------+
mysql> select * FROM STUFF;
+--------+--------+-------------------+
| S_ID | D_ID | S_TITLE |
+--------+--------+-------------------+
| 1 | 1 | plastic |
| 2 | 2 | metal |
| 3 | 3 | wood |
| 4 | 3 | gel |
+--------+--------+-------------------+
我使用下面的查詢
SELECT
d.D_NAME,
s.S_TITLE,
f.F_VALUE,
IF(r.CONFIDENCE IS NULL, 'N/A', CONCAT((r.CONFIDENCE),'%')AS CONFIDENCE
FROM F_THINGS f
JOIN STUFF s ON s.S_ID=f.S_ID
JOIN DUMP d on d.D_ID=s.D_ID
LEFT JOIN F_FINDINGS r ON f.F_ID=r.F_ID;
所需的結果:
+----------+-----------+------------+------------+
| D_NAME | S_TITLE | F_VALUE | CONFIDENCE |
+----------+-----------+------------+------------+
| E0 | plastic | 202.2 | 70% |
| E0 | plastic | 10.7 | N/A |
| E0 | plastic | 1.1 | 100% |
| A1 | metal | 540 | N/A |
| A1 | metal | 1080 | N/A |
| A1 | metal | 455 | N/A |
| AB | wood | 333 | N/A |
| AB | wood | 825 | N/A |
| E0 | gel | 103.4 | N/A |
| E0 | gel | 98.4 | N/A |
+----------+-----------+------------+------------+
我只想要顯示的最高值每個
你的「STUFF」樣本數據在哪裏......還有,最高值?或最高的信心?只要確保 – DRapp 2012-03-01 16:35:31
@DRapp我會添加'東西'表。對不起,我把它留下了。我想要最高的信心 – stackoverflow 2012-03-01 16:37:32
@VAShhh期望的輸出被列在最下面,它表示'期望的結果' – stackoverflow 2012-03-01 16:41:17