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
 SQL Server Development (2000)
 Sequencing in MSsql server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-29 : 07:28:01
Kalpan writes "i want sequential data as below can anybody help

select dateofservice,tblsortorder.orroomno from tblcasedata , tblsortorder
where tblcasedata.orroomno= tblsortorder.orroomno and dateofservice >= '8/25/2005' and
dateofservice <= '8/27/2005'
group by dateofservice ,tblsortorder.orroomno


sequence number which i have shown is not in the database but i want like this.

output wanted :-

orroomno dateof service sequenceno
1 8/26/2005 1
1 8/26/2005 2
2 8/26/2005 1
3 8/26/2005 1
3 8/26/2005 2
3 8/26/2005 3"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 07:34:07
I think it is not possible until you have primary key
If you have primary key then

Select orroomno,dateof_service,(select count(*) from yourTable where orroomno=T.orroomno
and dateof_service=T.dateof_service and PrimaryKey<=T.PrimaryKey) from yourTable T

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -