|
发表于 2020-6-8 20:30:01
|
显示全部楼层
估计楼主的意思是不要根据排序来做。
这样如何:
--建示例表:
create table #ddd
([id] int,[name] varchar(20),remark varchar(200)
)
insert into #ddd
select 1,'a','dsfadsf'
union
select 2,'b','dryh'
union
select 3,'c','uui'
union
select 4,'d','gjk'
union
select 5,'e','dsfradsf'
union
select 6,'f','dsfadsf'
union
select 7,'g','fdf'
union
select 8,'h','dfdf'
union
select 9,'i','jki'
union
select 10,'j','reta'
--查询语句
select * from
(
select top 8 a.* from (select * from #ddd) a
union all
select top 4 b.* from (select * from #ddd) b
) c
group by [id],[name],remark
having count(*)=1 |
|