sql 查询复数据并显示语句
//方法二
select name,content,imgurl,synois from (select name,content,imgurl,synopsis ,row_number() over (partition by name order by content) as rn from table1 ) t where t.rn=1
//方法二
if object_id(‘[tb]’) is not null drop table [tb]
create table [tb]([name] varchar(1),[content] varchar(5),[imgurl] varchar(5),[synopsis] varchar(6))
insert [tb]
select ‘a’,’不同1′,’不同1′,’可不填’ union all
select ‘a’,’不同2′,’不同2′,’可不填’ union all
select ‘a’,’不同3′,’不同3′,’可不填’ union all
select ‘b’,’不同4′,’不同4′,’可不填’ union all
select ‘b’,’不同5′,’不同5′,’可不填’ union all
select ‘c’,’不同6′,’不同6′,’可不填’select * from [tb]
with tt
as(
select id = row_number() over (partition by name order by name ),* from tb )select [name], [content], imgurl, synopsis from tt where id = 1
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/1836880.html