多列的SQL DISTINCT查询 [英] SQL DISTINCT query on Multiple Columns

查看:614
本文介绍了多列的SQL DISTINCT查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的表:

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,这与返回哪条记录无关.这就是我要寻找的:

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

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

I am using ASP on a MS Access database.

非常感谢您的帮助.

推荐答案

访问权限具有FIRSTLAST聚合,其中r

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

这篇关于多列的SQL DISTINCT查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆