日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

排除字段重复行的SQL

發布時間:2025/4/16 56 豆豆
生活随笔 收集整理的這篇文章主要介紹了 排除字段重复行的SQL 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
排除字段重復行的SQL

--
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[test]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[test]
GO

CREATE TABLE [dbo].[test] (
?[id] [int] IDENTITY (1, 1) NOT NULL ,
?[name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
?[score] [int] NULL
) ON [PRIMARY]
GO
truncate table test
Insert into test(name,score)
select 'a',11 union
select 'b',22 union
select 'b',33 union
select 'c',44 union
select 'c',55
--

SELECT * FROM test

select * from test where [id] in (select [id] from
?(
??select name,id=(select min([id]) from test where [name]=test1.name) from
??(select distinct [name] from test)test1
?)test2
)

或者

select * from test where [id] in(select min([id]) from test group by name)

?


posted on 2007-11-30 11:13 郭大俠 閱讀(...) 評論(...) 編輯 收藏

轉載于:https://www.cnblogs.com/guodaxia/archive/2007/11/30/978027.html

總結

以上是生活随笔為你收集整理的排除字段重复行的SQL的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。