I have SQL query:
SELECT min(m.density), m.metal_name
FROM metal m
INNER JOIN storage s ON m.id = s.metal_id
GROUP BY m.metal_name;
As a result I get:
+-----------+--------------+
| m.density | m.metal_name |
+-----------+--------------+
| 1200 | GOLD |
+-----------+--------------+
| 1200 | TIN |
+-----------+--------------+
| 1600 | COPPER |
+-----------+--------------+
| 1800 | PLATINUM |
+-----------+--------------+
My desired result is something like this (only minimum values of density):
+-----------+--------------+
| m.density | m.metal_name |
+-----------+--------------+
| 1200 | GOLD |
+-----------+--------------+
| 1200 | TIN |
+-----------+--------------+
There is a simple way to achieve this result?
You could try something like this:
Select the metals and their densities as far as the density equals the minimum density available in storage.