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
 General SQL Server Forums
 New to SQL Server Programming
 Help needed with what i think you call a nested qu

Author  Topic 

nobby
Yak Posting Veteran

58 Posts

Posted - 2006-10-19 : 23:23:47
i need this statement to run but if this field bl_01030_Tour_Schedule.Sch_TourStartDate is >= GETDATE()
Then only SELECT TOP (1)

Cheers...

SELECT TOP (2) Tbl_01030_Tour_Schedule.Sch_TourId,
Tbl_01020_Tour_Types.TourTypeId,
Tbl_01020_Tour_Types.TourGame,
Tbl_01020_Tour_Types.TourDescr,
Tbl_01030_Tour_Schedule.Sch_TourStartDate,
Tbl_01030_Tour_Schedule.Sch_TourEndDate,
CASE
WHEN (Sch_TourStartDate) < getdate()
THEN ToursPerBilling_EnterNow ELSE ToursPerBilling
END AS Initial_TourQty,
CASE
WHEN (Sch_TourStartDate) < getdate()
THEN TourRecurringBillAmount_EnterNow ELSE TourRecurringBillAmount
END AS Initial_TourCost

FROM Tbl_01020_Tour_Types INNER JOIN
Tbl_01030_Tour_Schedule ON Tbl_01020_Tour_Types.TourTypeId = Tbl_01030_Tour_Schedule.Sch_TourTypeId
WHERE (Tbl_01030_Tour_Schedule.Sch_TourEndDate > GETDATE()) AND (Tbl_01020_Tour_Types.TourTypeId = @_TourTypeId)
ORDER BY Tbl_01030_Tour_Schedule.Sch_TourStartDate

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-20 : 09:16:34
Duplicate of http://sqlteam.com/forums/topic.asp?TOPIC_ID=73811

Madhivanan

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

- Advertisement -