如果是唯一数据的,肯定是有约束条件来确认结果的唯一性,肯定会用到where语句。
sql:select * from tablename where id ='10';
解释:如果id是主键或者是不重复字段,那么通过固定的id条件,就可以取出唯一数据。
楼上各位写的语句是不对的,标准答案如下:
select distinct 字段D,
(select top 1 字段A from tb where 字段D=A.字段D) as 字段A,
(select top 1 字段B from tb where 字段D=A.字段D) as 字段B,
(select top 1 字段C from tb where 字段D=A.字段D) as 字段C
from tb A
select * from tableName as t where
not exists (select 1 from tableName where d=t.d and id
这样读出来的如果重复读出来的是第一个
不明白的,百度Hi我。
SELECT 字段A,字段B,字段C
FROM 表
WHERE (字段D IN
(SELECT 字段D
FROM 表
GROUP BY 字段D
HAVING COUNT(*) = 1))
select * from TABLE a where a.字段A = (select MIN(字段A) from TABLE where 字段D = a.字段D) order by 字段D asc;