MySQL计数选择查询条件

时间:2015-12-15 15:55:39

标签: mysql sql select count conditional-statements

我有一个名为Game的mysql表,它有两列,Name和Score。我想只选择分数至少为100且至少两次的名字。在下面的例子中,Ron和Mary将被选中。我不知道如何为此编写select语句。

游戏桌

enter image description here

1 个答案:

答案 0 :(得分:3)

public static string RemoveWhiteSpaceFromStylesheets(string body) { body = Regex.Replace(body, @"[a-zA-Z]+#", "#"); body = Regex.Replace(body, @"[\n\r]+\s*", string.Empty); body = Regex.Replace(body, @"\s+", " "); body = Regex.Replace(body, @"\s?([:,;{}])\s?", "$1"); body = body.Replace(";}", "}"); body = Regex.Replace(body, @"([\s:]0)(px|pt|%|em)", "$1"); // Remove comments from CSS body = Regex.Replace(body, @"/\*[\d\D]*?\*/", string.Empty); return body; } GROUP BY子句一起使用:

HAVING

SELECT Name FROM mytable GROUP BY Name HAVING COUNT(CASE WHEN Score >= 100 THEN 1 END) >= 2 子句检查HAVING个群组,至少有两个记录Name