Author |
Topic |
nextaxtion
Yak Posting Veteran
54 Posts |
Posted - 2014-07-09 : 06:41:20
|
hi team , i have following data and i need to display groouped data as i mentioned below. declare @tbl table (id numeric(10) , name varchar(100))insert into @tbl (id, name)values(10, 'a')insert into @tbl (id, name)values(10, 'b')insert into @tbl (id, name)values(10, 'c')insert into @tbl (id, name)values(20, 'a')insert into @tbl (id, name)values(20, 'b')insert into @tbl (id, name)values(20, 'c')insert into @tbl (id, name)values(30, 'a')insert into @tbl (id, name)values(30, 'b')insert into @tbl (id, name)values(30, 'c') output : sno id name 1 10 a 2 10 b 3 10 c 1 20 a 2 20 b 3 20 c 1 30 a 2 30 b 3 30 c and i had done this with row_nuumber function and it works good but i want to do this by some other method. pls help prithvi nath pandey |
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2014-07-09 : 10:57:52
|
WHat are you trying to make it look like?declare @tbl table (id numeric(10) , name varchar(100))insert into @tbl (id, name)values (10, 'a'), (10, 'b'), (10, 'c'), (20, 'a'), (20, 'b'), (20, 'c'), (30, 'a'), (30, 'b'), (30, 'c') Select * From @tbl Group By id, name Order By idWe are the creators of our own reality! |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2014-07-09 : 12:09:22
|
quote: Originally posted by nextaxtion i had done this with row_nuumber function and it works good but i want to do this by some other method. pls help
Do you mean you don't want to use a ranking function (like ROW_NUMBER) or is it ok to use another ranking function like RANK?What version of SQL server are you using? If you don't want to use a ranking function, why do you not want to use one (as that is what they are made for)? |
 |
|
|
|
|