我有一张桌子
NAME | BONUS
----------------
anil | 40
suresh | 25
ramesh | 44
anil | 35
anil | 15
我想删除name = anil and bonus < max bonus of anil
OUTPUT
anil | 40
suresh | 25
ramesh | 44
我尝试了查询:
delete from table where name like 'anil' and bonus < (select max(bonus)
from table where name like 'anil';
但它给出了语法错误。 谁能帮忙。我会感恩的。
答案 0 :(得分:0)
您缺少子查询的结束括号:
delete from table
where
name like 'anil' and
bonus < (select max(bonus) from table where name like 'anil'
应该是
delete from table
where
name like 'anil' and
bonus < (select max(bonus) from table where name like 'anil')
答案 1 :(得分:0)
您需要使用具有聚合函数的Group by。
检查以下查询是否相同。
delete from table where bonus < (select max(bonus) from table where name like 'anil' Group By name)
答案 2 :(得分:0)
“table”这个词是一个保留的SQL关键字,我认为你的错误指的是
您无法在FROM子句
中为更新指定目标表'table'