Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want the display data like below format.
1 1
2 1
2 2
3 1
3 2 
3 3
4 1
4 2
4 3
4 4
5 1
5 2
5 4
.
.
.
.
7 6
7 7
after 7 then
8 8
9 8
9 9
10 8
.
.
.
.
100 99
100 100

i want upto 100
Posted
Updated 16-Aug-13 0:18am
v3
Comments
walterhevedeich 16-Aug-13 3:54am    
Looks like a homework. :-) Have you tried anything?
Thanks7872 16-Aug-13 5:07am    
Just an abuse,no less.
ArunRajendra 16-Aug-13 4:07am    
Is this data in the table or you want to generate?
sampath1750 16-Aug-13 4:36am    
table data only,
in my table only 2 columns.
sampath1750 16-Aug-13 4:38am    
i tried using while loop, but data not coming properly

Try this code!!Hope you will njoy it :)

SQL
CREATE TABLE #temp1(
Numbers int
)
/**********/
	DECLARE @idt INT 
	Declare @count int
	SET @idt = 0
	SET @count=0
	WHILE (@idt < 100)
	BEGIN
		SELECT @idt = @idt + 1
		SELECT @count=1
		WHILE(@idt>=@count)
			BEGIN
				SELECT @count = @count + 1
				insert into #temp1(Numbers)values(@idt)
				--print @idt
			END
	END
/**********/
Select Numbers,ROW_NUMBER() Over(Partition by Numbers order by Numbers) As RowNum  from #temp1 

Select * from #temp1
 
Share this answer
 
v2
Comments
gvprabu 16-Aug-13 10:09am    
nice work
RedDk 16-Aug-13 13:34pm    
Good answer. (OP was intimating the whole 1,100,20,200 disconnnect)
use while loop with proper conditions and solve this puzzel
Happy Coding!
:)
 
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