toastedDeli toastedDeli - 1 year ago 108
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download