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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Page Number to each row in SQL 2000

Author  Topic 

abhijeetdighe
Starting Member

24 Posts

Posted - 2009-10-26 : 07:20:26
Hi

My query is returning some result. I want to add one more column to this query as PageNo.

Suppose if my query is returning 35 records, then

PageNo column should contain 1 for records 1-10,
then PageNo column should contain 2 for records 11-20,
then PageNo column should contain 3 for records 21-30,
and then PageNo column should contain 4 for remaining records 31-35.

How to write query for this?

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-10-26 : 09:57:54
[code]
create table #t (id int)

declare @i int
set @i = 1
while @i <= 35
begin
insert #t values (@i)
set @i = @i + 1
end

select id, ceiling(id/10.0) as PageNo from #t

drop table #t[/code]
Go to Top of Page
   

- Advertisement -