我正在尝试根据性别是男孩的情况在我的数据库中显示姓名。我目前正在尝试此查询,但它似乎无法正常工作。
SELECT
Name,
COUNT(Name),
Gender='Boy' AS totalNumber
FROM
finaldb
GROUP BY
Name,
Gender
ORDER BY
COUNT(Name) DESC
LIMIT 5
有什么建议吗?
答案 0 :(得分:1)
我认为Gender='Boy'
位于错误的位置,将其置于WHERE
SELECT
Name,
Gender,
COUNT(Name) AS totalNumber
FROM
finaldb
WHERE
Gender='Boy'
GROUP BY
Name,
Gender
ORDER BY
COUNT(Name) DESC
LIMIT 5
阅读WHERE和SQL的好地方: