toastedDeli toastedDeli - 3 months ago 38
SQL Question

How to find minimum values in a column in sql

If I have a table like this:

id name value
1 abc 1
2 def 4
3 ghi 1
4 jkl 2

How can I select a new table that still has
id, name, value
but only the ones with a minimum value.

In this example I need this table back:

1 abc 1
3 ghi 1


Finding those values is pretty straightforward:

FROM YourTable
WHERE value = (SELECT MIN(Value) FROM YourTable);

As for the right syntax for putting those rows in another table, that will depend on the database engine that you are using.