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.
| Author |
Topic |
|
hoffmandirt
Starting Member
1 Post |
Posted - 2007-09-25 : 13:29:13
|
| I would like to give the user of a website the ability to input an event that can have many dates and times. So for example, the user enters "Walk the Dog" as the event and then says I want this event to happen October 1st at 1pm, October 5th at 2pm, and October 9th at 5am. Here are the tables I came up with.Events----------eventId PKeventTitleeventDetailsEventDateTimes-------------------eventId PK,FKeventDateTime PKThe problem comes when I want to display the top N events on the homepage. I am not sure how to write the SELECT statement to sort the events by date/time where eventDateTime is greater than today's date. So basically here is what I am looking to see on the home page.Events sorted by date where the event's ending soonest will be at the top of the list.The date/time for the event that is greater than or equal to today's date, but not the max date. I don't want "Walk the Dog" to show up 3 times. Just once with the closest date that is greater than or equal to today's date. So, distinct events.Maybe this is not the best way to set these tables up. Let me know what you guys/girls think about this. Let me know if I can elaborate more.Thanks! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-09-25 : 13:35:33
|
Please post some sample data and expected output. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|