Contents

1
2 2000 覯 豌襴 覦覯
3 2005 伎 覯 豌襴 覦覯
4 SQL覓語 豌襴 觜 觜蟲
5 蠏朱蓋


1 #

貉るる一 覲企 螳 譴覲牛 蟇壱螻 矩る 讌覓碁れ 殊り . 襯 れ れ螻 螳 蟆曙磯.
-- 企 
CREATE TABLE MEMBER( 
	IDX int identity(1,1)
,	NAME Char(20) 
)
GO

-- 一危 
INSERT INTO MEMBER VALUES('A') 
INSERT INTO MEMBER VALUES('A') 
INSERT INTO MEMBER VALUES('B') 
INSERT INTO MEMBER VALUES('B') 
INSERT INTO MEMBER VALUES('B') 
INSERT INTO MEMBER VALUES('B') 
INSERT INTO MEMBER VALUES('C') 
INSERT INTO MEMBER VALUES('C')
GO

2 2000 覯 豌襴 覦覯 #

蠏朱蓋 願屋 覦覯 . 譴覲旧 覦讌 蟆曙 襷 蟆 譴.

--2000危 覯
DELETE FROM MEMBER 
WHERE IDX IN ( 
	SELECT A.IDX as IDX 
	FROM MEMBER A INNER JOIN (
			SELECT 
				MAX(IDX) AS IDX
			,	NAME AS NAME 
			,	COUNT(*)  AS CNT 
			FROM MEMBER 
			GROUP BY NAME 
			HAVING COUNT(*) >1) B
	ON A.NAME = B.NAME  
	AND A.IDX!=B.IDX 
)

3 2005 伎 覯 豌襴 覦覯 #

--2005伎 覯( 襭覲企   觜朱 豌襴  )
DELETE A
FROM 
(
	SELECT 
		IDX
	,	NAME
	,	ROW_NUMBER() OVER(PARTITION BY NAME ORDER BY IDX) NUM
	FROM MEMBER
) A
WHERE NUM <> 1

4 SQL覓語 豌襴 觜 觜蟲 #

cost.jpg

一危郁 朱 讌 觜谿襯 蟆 覈 讌襷, 襷 焔レ姶願 .

5 蠏朱蓋 #

譴覲牛 蟇磯 Unique伎 一危郁 Unique讌 蠍 覓語. 豐 譴覲旧 覦 語 谿場 . DBり レ 覲碁る Unique 曙^蟇伎 蟇語 蠍 覓語願, DBり 伎 覲碁る 豌 ろ れ 襦 覦讌 覈詩伎 蠍 覓語. れ 襦 覦 蟆 り 蠍磯蓋 譴 蠍磯蓋企.