Possible to do a delete with a HAVING clause?

前端 未结 5 1519
野性不改
野性不改 2020-12-06 04:02

I want to do something like below:

DELETE UserPredictions
  GROUP BY UserId
  HAVING COUNT(*) < 500

But I\'m getting a syntax error. Is

5条回答
  •  情歌与酒
    2020-12-06 04:56

    Try this nested query:

    DELETE FROM UserPredictions  
    WHERE UserId IN (SELECT UserId
                     FROM UserPredictions 
                     GROUP BY UserId
                     HAVING COUNT(*) < 500)
    

提交回复
热议问题