求一个简单的数据库查询SQL
数据库中表tb_A有3个字段:
ID int IDENTITY (1,1) PRIMARY KEY,
A INT NOT NULL,
B NVARCHAR (50)
问题是这样:
如果我需要查询出来tb_A中的A字段信息,按照ID进行倒序排列,A字段中有重复字段,要求去除重复。
请各位大侠帮忙看看该怎么写
------解决方案----------------------包含B
select a.* from tb_a where id = (select min(id) from tb_a group by a)
select a.* from tb_a a,
(select a,min(id) id from tb_a group by a) b
where a.id = b.id and a.a = b.a
select a.* from tb_a where id in (select min(id) from tb_a group by a)