问候, 我正在尝试构建一个查询,它将为我提供两个日期之间所有记录(一些记录重复出现)的总计。我陷入了以下问题:
SELECT DISTINCT Country, COUNT(Country) as Count, Date
From DataSet
GROUP BY Country, Date
ORDER BY Country HAVING Date>'1/1/2000'
提前致谢。
答案 0 :(得分:0)
SELECT DISTINCT Country, COUNT (Country) AS COUNT
FROM DataSet
WHERE Date BETWEEN '01-01-2010' AND '01-01-2011'
GROUP BY Country
ORDER BY Country
您不应按日期分组,因为您将获得每一个日期
答案 1 :(得分:0)
SELECT Country, COUNT(DISTINCT Country) as "Count"
FROM DataSet GROUP BY Country, Date
HAVING Date>'1/1/2000';
因为HAVING
没有通过ok coorect设置顺序