Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
goodsolution
Starting Member
38 Posts |
Posted - 2009-05-08 : 11:37:33
|
| Hi all, I have an input table called "TABLE1", it is having values as follows Col1NameANameANameANameBNameBNameBNameBNameCNameCI want to display the o/p in "TABLE2" as shown belowid Col11 NameA1 NameA1 NameA2 NameB2 NameB2 NameB2 NameB3 NameC3 NameCNote: I am having nearly million records in my table-Thanks |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-05-08 : 11:55:18
|
| DECLARE @Table1 TABLE (Col1 char(5))DECLARE @Grp intDECLARE @col1 char(5)SET @Grp = 1INSERT INTO @Table1SELECT 'NameA' UNION ALLSELECT 'NameA' UNION ALLSELECT 'NameA' UNION ALLSELECT 'NameB' UNION ALLSELECT 'NameB' UNION ALLSELECT 'NameB' UNION ALLSELECT 'NameB' UNION ALLSELECT 'NameC' UNION ALLSELECT 'NameC' select dense_rank() over(order by col1) ,col1from @table1Jim |
 |
|
|
|
|
|