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 |
|
rvegas
Starting Member
1 Post |
Posted - 2009-09-14 : 01:28:22
|
| Hi all,I'm not sure if this is possible to do; but if it is I will really appreciate any help.I have a table like this :ID DATE TYPE1 2009-11-23 21:00:00 22 2009-06-05 21:00:00 13 2009-07-31 21:00:00 04 2008-04-20 01:00:00 05 2009-04-21 01:00:00 06 2009-04-18 21:00:00 37 2008-04-19 21:00:00 08 2009-06-04 21:00:00 7...All these are event dates.Type 0 are events that only occur 1 time (one time events), all other are recurring event (weekly events), where the date is the first occurrence of the event and the type is the day of the week where they occur (1=mon, 2= tue, etc)Question:How can I create a Select query that returns the 10 upcoming events Including one time events and recurring events?Would I be able to use OFFSET 10 to then get the following 10 events?Thanks! |
|
|
ams006
Yak Posting Veteran
55 Posts |
Posted - 2009-09-14 : 10:30:40
|
| Try this, select top 10 *from {tablename}order by {datefield} desc Regardsams006 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-09-14 : 11:01:13
|
| are you using sql server? limit is not available in sql server. you need to use top instead. also you should order by date asc if you're looking for first 10 upcoming events |
 |
|
|
|
|
|