sushilb (10/3/2011)
Well the condition should not on 13 rows before , it should be on thirteenths days beforeas below
select ID,
Symbol_Code,
Transaction_date,
Close_Price
from EOD_NSE_Stock
where
Transaction_date between
dateadd(day, -13, getdate()) and getdate()
and
Symbol_Code=@Symbol_Code
so there might be possibilty that i may miss some rows becoz of having holiday on some days.
thats why i m checking the the if else conditionto have exact 13 days data .
So missing days - holidays and weekends - are included in the 13 days?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden