+--------------+------+------------------------------------+-------+
| ProductCode | Qty | Title | Price |
+--------------+------+------------------------------------+-------+
| relationaldb | NULL | The Relational Database Dictionary | 14.99 |
| artofsql | 50 | The Art of SQL | 44.99 |
| databaseid | 0 | Database in Depth | 29.95 |
| mysqlspp | 5 | MySQL Stored Procedure Programming | 44.99 |
| sqlhks | 32 | SQL Hacks | 29.99 |
| sqltuning | 105 | SQL Tuning | 39.95 |
+--------------+------+------------------------------------+-------+
The table above was selected from the following select statement.
mysql> SELECT P.ProductCode, MAX(I.QuantityInStock) as Qty, P.Title, P.Price
FROM Products as P
LEFT JOIN Inventory as I on (P.ProductCode = I.ProductCode)
GROUP BY I.ProductCode, P.Title, P.Price;
What is the max function and the group by statements really doing?