tags:

views:

452

answers:

1

i want t0 delete a row with minimum value of a particular field from a table if number of records less than 5;

+5  A: 

You can do this with sub-selects for the aggregate min and count functions:

DELETE FROM the_table WHERE
  the_field = (SELECT min(the_field) FROM the_table)
  AND (SELECT count(*) FROM the_table) < 5;
Matt Good