COUNT(*) returning multiple rows instead of just one

后端 未结 4 1704
春和景丽
春和景丽 2020-12-16 23:19

Why does COUNT() return multiple rows when I just need the total count of how many rows my query generates?

Should return 1078.

4条回答
  •  自闭症患者
    2020-12-16 23:51

    Well, simple answer. Don't GROUP BY if you don't need groups.

    Either use COUNT(DISTINCT articles.company) without GROUP BY or keep the the GROUP BY and wrap the whole query in a SELECT COUNT(*) FROM (...) AS data, if you want to count the groups.

提交回复
热议问题