-
Sequencing in MSSQL
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"
-
re: Sequencing in MSSQL
select orroomno, dateofservice, (select count(*) from test where id>=t.id and orroomno=t.orroomno) a
from test t Order By orroomno,a
--For this u need to have an Identity COlumn
In the above query the tablename is TEST
Hope it helps
Rachit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|