|
|
|
Click here to copy the following block | CREATE TABLE #Test (Description CHAR(5)); INSERT #Test VALUES('AAAAA'); INSERT #Test VALUES('BAAAB'); INSERT #Test VALUES('HAAAB'); INSERT #Test VALUES('MMMMM'); INSERT #Test VALUES('TAAAR'); INSERT #Test VALUES('XXXXZ'); INSERT #Test VALUES('ZZZZA'); SELECT * FROM #Test;
GO
SELECT t1.DESCRIPTION, SUM(CASE WHEN t2.DESCRIPTION <= t1.DESCRIPTION THEN 1 ELSE 0 END) AS Sequence FROM #Test t1 CROSS JOIN #Test t2 GROUP BY t1.DESCRIPTION ORDER BY t1.DESCRIPTION;
SELECT t1.DESCRIPTION, (SELECT COUNT(*) FROM #Test t2 WHERE t2.DESCRIPTION <= t1.DESCRIPTION) AS Sequence FROM #Test t1 ORDER BY t1.DESCRIPTION;
|
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|