如何在ms访问中使用DISTINCT?
How to use DISTINCT in ms access?
我有以下查询:
SELECT DISTINCT AwardDescriptions.aID, CostCentres.cCC
FROM AwardDescriptions
INNER JOIN CostCentres ON AwardDescriptions.aID = CostCentres.cNumber
ORDER BY CostCentres.cCC;
出于某种原因,当我 运行 我的查询时,它仍然显示所有重复值。
有什么建议吗?
您可以使用 group by
并获取最小值或最大值:
SELECT MAX(AwardDescriptions.aID) as aID, CostCentres.cCC
FROM AwardDescriptions INNER JOIN
CostCentres
ON AwardDescriptions.aID = CostCentres.cNumber
GROUP BY CostCentres.cCC
ORDER BY CostCentres.cCC;
我有以下查询:
SELECT DISTINCT AwardDescriptions.aID, CostCentres.cCC
FROM AwardDescriptions
INNER JOIN CostCentres ON AwardDescriptions.aID = CostCentres.cNumber
ORDER BY CostCentres.cCC;
出于某种原因,当我 运行 我的查询时,它仍然显示所有重复值。 有什么建议吗?
您可以使用 group by
并获取最小值或最大值:
SELECT MAX(AwardDescriptions.aID) as aID, CostCentres.cCC
FROM AwardDescriptions INNER JOIN
CostCentres
ON AwardDescriptions.aID = CostCentres.cNumber
GROUP BY CostCentres.cCC
ORDER BY CostCentres.cCC;