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)
 i want rows of yesterday if today's....

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2006-07-08 : 05:09:22
Dear

I have created a stored procedure with 1 parameter like below.

CREATE PROCEDURE SP_news_date
(
@news_date datetime
)

AS

-- For local news -0
SELECT top 4 * from allnews where news_name='news' and sub_name='Kingdom' and en_date=@news_date ORDER BY en_date DESC
-- For Middle East new -1
SELECT top 4 * from allnews where news_name='news' and sub_name='Middle East' and en_date=@news_date order by en_date DESC
--For Asia News - 2
SELECT top 4 * from allnews where news_name='news' and sub_name='Asia' and en_date=@news_date order by en_date DESC
--For International news - 3
SELECT top 4 * from allnews where news_name='news' and sub_name='International' and en_date=@news_date order by en_date DESC

here i am passing @news_date = today's date

now,

I want some programming for

IF there is nothing for today then it must fetch yesterday's records,

Please help me out

Waiting for reply

regards,
ASIF

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-07-08 : 05:36:51
and en_date <= @news_date order by en_date DESC


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-07-10 : 02:50:21
>>IF there is nothing for today then it must fetch yesterday's records,

Only yesterday's records or all previous days records?

Madhivanan

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

- Advertisement -