SQL DISTINCT query on Multiple Columns

人盡茶涼 提交于 2019-12-31 01:52:27

问题


I have a table like this:

Artist   Image   Title

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

And I want to set up a DISTINCT Query to return the Artist once - doesn't matter which of the records are returned. This is what I'm looking for:

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

I am using ASP on a MS Access database.

Any help much appreciated.


回答1:


Access has FIRSTand LAST aggregates which return 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


来源:https://stackoverflow.com/questions/5407480/sql-distinct-query-on-multiple-columns

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!