我有以下查询:
SELECT DISTINCT AwardDescriptions.aID, CostCentres.cCC
FROM AwardDescriptions
INNER JOIN CostCentres ON AwardDescriptions.aID = CostCentres.cNumber
ORDER BY CostCentres.cCC;
出于某种原因,当我运行查询时,它仍然显示所有重复的值。 有什么建议吗?
答案 0 :(得分:1)
您可以使用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;