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)
 Complex query based on date criteria

Author  Topic 

robc
Yak Posting Veteran

60 Posts

Posted - 2004-10-05 : 13:33:48
Hi,

Here is my situation. I have an application that allows a user to enter dates for events. Now sometimes they enter dates in advance. What I have is a page that displays the next upcoming event.

My problem lies here. I don't know how to retrieve the the upcoming event if there are other events posted with a later date.

my table looks like so.

id - id of event
displayDate - the displayed date of the event
beginDate - the begin date of the event for sorting purposes.
details - details of the event.

would this best be handled by a complex sql query?

Rob


Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-05 : 14:07:59
Select *
From <eventTable>
Where <eventDateCol> = (Select min(<eventDateCol>) From <eventTable> Where <eventDateCol> >= @dateParam)

Corey
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-05 : 14:10:26
not paying attention...

Select *
From <eventTable>
Where displayDate = (Select min(displayDate) From <eventTable> Where displayDate >= @dateParam)

Corey
Go to Top of Page
   

- Advertisement -