多列上的SQL DISTINCT查询

时间:2011-03-23 15:19:06

标签: sql ms-access

我有一张这样的表:

Artist   Image   Title

Smith    2       Country
Smith    5       Town
Doyle    21      Cat
Lawlor   24      Ball
Jones    8       Cheese
Jones    12      Bread
Jones    15      Butter

我想设置一个DISTINCT查询以返回艺术家一次 - 无论返回哪个记录都无关紧要。这就是我要找的东西:

Artist   Image   Title
Smith    2       Country
Doyle    21      Cat
Lawlor   24      Ball
Jones    8       Cheese

我在MS Access数据库上使用ASP。

任何帮助都非常感激。

1 个答案:

答案 0 :(得分:2)

访问权限包含FIRSTLAST聚合,其中r eturn the first or last record as it was entered in chronological order

SELECT Artist, FIRST(Image) AS Image, FIRST(Title) AS Title
FROM table
GROUP BY Artist