Contents

1
2 SQL Server 2000 覯
3 SQL Server 2005 伎 覯


1 #

蠏碁9覲 覯 襷り鍵 螳 螳螳 type 伎 覯 襷り鍵 蟆 襷.
seq         type         title                                                                             
----------- ------------ --------------------------------------------------------------------------------  
1           business     Straight Talk About Computers 
2           business     The Busy Executive's Database Guide 
3           business     Cooking with Computers: Surreptitious Balance Sheets 
4           business     You Can Combat Computer Stress! 
1           mod_cook     The Gourmet Microwave 
2           mod_cook     Silicon Valley Gastronomic Treats 
1           popular_comp Secrets of Silicon Valley 
2           popular_comp Net Etiquette 
3           popular_comp But Is It User Friendly? 
1           psychology   Emotional Security: A New Algorithm 
2           psychology   Computer Phobic AND Non-Phobic Individuals: Behavior Variations 
3           psychology   Is Anger the Enemy? 
4           psychology   Life Without Fear 
5           psychology   Prolonged Data Deprivation: Four Case Studies 
1           trad_cook    Sushi, Anyone? 
2           trad_cook    Onions, Leeks, and Garlic: Cooking Secrets of the Mediterranean 
3           trad_cook    Fifty Years in Buckingham Palace Kitchens 
1           UNDECIDED    The Psychology of Computer Cooking 

2 SQL Server 2000 覯 #

SELECT title, type, IDENTITY(INT, 1, 1) seq INTO #temp 
FROM titles 

SELECT seq%cnt + 1 seq, a.type, a.title 
FROM #temp a  
	INNER JOIN ( 
		SELECT  
			MIN(type) type 
		,	COUNT(*) cnt 
		FROM titles 
		GROUP BY type) b 
ON a.type = b.type 
ORDER BY a.type, seq%cnt + 1 

DROP TABLE #temp 

--企 覯 襷り鍵 伎  蟆企.. 
-- る狩伎 rownum  蟆 谿 暑. 企 襷れ 螻 覯 襷  朱 
--覯 襷り鍵 蟆 企  蟆 覿螳  . れ 貎朱Μ I/O襯 觜蟲 覲企  蟆企. 
--2005覯 Row_Number()襯 伎覃 . 

SELECT COUNT(*) seq, a.title_id, a.type 
FROM titles a INNER JOIN titles b 
ON a.type = b.type  
AND a.title_id >= b.title_id 
GROUP BY a.title_id, a.type 

3 SQL Server 2005 伎 覯 #

2005 伎 覯 Windowing Functiion 危襯 谿瑚.