如果行中的两列有最大值,我试图删除Rows。或者它同时具有MIN列和MAX列。
BEGIN
DELETE FROM scores WHERE (second, third)
IN ((MAX(second),MAX(third)));
select * from scores;
END
我有三列第一,第二和第三列。我试图从上面的查询做的,我试图删除行,如果第二个和第三个从其列具有最大值。它给了我一个错误。
ERROR 1111 (HY000) at line 70: Invalid use of group function
我该如何解决这个问题?
答案 0 :(得分:0)
你需要分别写两个条件,试试这个:
DELETE s.* FROM scores s
WHERE second = (SELECT second FROM (SELECT MAX(second) AS second FROM scores) a)
AND third = (SELECT third FROM (SELECT MAX(third) AS third FROM scores) b);