Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a table A with 2 columns

f1 f2
A   1
A   2
A   3
B   1
B   2
B   3

I want the out put in the below format

Sl.No  F1 F2
1       A  1
2       A  2
3       A  3
1       B  1
2       B  2
3       B  3


Thanks in Advance
Saju


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 2-Sep-13 21:03pm
v2

Try
SQL
SELECT f2 AS [Sl.No], f1 AS F1, f2 AS F2 FROM A
 
Share this answer
 
Comments
ridoy 3-Sep-13 3:09am    
5ed!
Peice of cake.. Use RankingFunctions[^]
SQL
Select Row_Number() Over(Partition by f1 Order by f2) as [Sl.No],f1 as [F1],f2 as [F2] From TableA 
 
Share this answer
 
v3
Comments
saju A Salim 3-Sep-13 3:18am    
Thanks Rajasekhar
Raja Sekhar S 3-Sep-13 3:24am    
Glad to help....
SQL
select (rank() OVER(ORDER BY [f2])) as SerialNo,f1,f2 from TableA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900