讓我們了解如何在 MySQL 中尋找每組列的最大值 -
SELECT colName1, MAX(colName2) FROM tableName GROUP BY colName1 ORDER BY colName1;
我們現在將看到一個實例。假設我們有一個表格PRODUCT -
+---------+--------+ | Article | Price | +---------+--------+ | 1 | 255.50 | | 1 | 256.05 | | 2 | 90.50 | | 3 | 120.50 | | 3 | 123.10 | | 3 | 122.10 | +---------+--------+
以下是取得每組最大列數的查詢-
SELECT Article, MAX(Price) AS MaxPrice FROM Product GROUP BY Article ORDER BY Article;
+--------------+--------------+ | Article | MaxPrice | +--------------+--------------+ | 0001 | 256.05 | | 0002 | 90.50 | | 0003 | 123.10 | +--------------+--------------+
以上是MySQL 中每組的最大列數的詳細內容。更多資訊請關注PHP中文網其他相關文章!