我试图在我的网站上获取国家访问次数。我有一个带有uid,国家和日期的SQL表。我然后尝试从SQL中提取计数,我需要在有序数组中计数,如
自从我使用SQL查询以来,已经很长时间了,我相信它的GROUP BY失败了。
SELECT COUNT(cfCountry) AS count FROM countryTracking GROUP BY cfCountry
但这只会回归:
如何让它返回订购的国家/地区以及前面的国家?
答案 0 :(得分:0)
你可以尝试添加像这样的计数
SELECT
country,
COUNT(country) as count
FROM countryTracking
GROUP BY country
ORDER BY COUNT(country)
答案 1 :(得分:0)
SELECT COUNT(cfCountry) AS COUNT,
cfCountry
FROM countryTracking
GROUP BY cfCountry
ORDER BY COUNT DESC;
答案 2 :(得分:-1)
只需在计数旁边添加要显示的字段,就应在结果集中显示此字段。
SELECT cfCountry, COUNT(cfCountry) AS count
FROM countryTracking c
GROUP BY cfCountry