标签: sql sqlite
如果记录数小于5,我希望t0从表中删除一个具有最小值的行;
答案 0 :(得分:6)
您可以使用汇总min和count函数的子选择来执行此操作:
min
count
DELETE FROM the_table WHERE the_field = (SELECT min(the_field) FROM the_table) AND (SELECT count(*) FROM the_table) < 5;