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)
 sqlserver 2000

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-01-25 : 08:16:33
seetaramaiah writes "i want to display a row from the table based on some condition,

how many rows continuously satisfy the condition and with in this continuously satisfy records get the starting record means like

RptDate Status
2005-12-01 N
2005-12-02 Y
2005-12-03 Y
2005-12-04 N
2005-12-05 Y
2005-12-06 N
2005-12-07 Y
2005-12-08 Y
2005-12-09 Y

i want to get the result like RptDate=2005-12-07 and Continuosly satisfy the latest dates status='y' is 3"

nr
SQLTeam MVY

12543 Posts

Posted - 2006-01-25 : 09:02:57
You mean you wanty to find the sequence of rows later than 2005-12-07 which are all 'y'?

select *
from tbl t
where RptDate > '20051207'
and not exists (select * from tbl t2 where t2.RptDate <= t.RptDate and t2.RptDate > '20051207' and t2.Status <> 'y')


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -