[thelist] SQl: Top xx
rudy
r937 at interlog.com
Wed Apr 11 16:24:55 CDT 2001
> I'm looking for a generic SQL way to get the latest x number
> of records based on date. I know on MS SQL Server I can
> use TOP, but I don't think that is "cross-database" compatible.
> Right now, I am using the MaxRows attribute of CFQUERY to
> limit the number, but I'd rather do it in the query. This is for an
> application that could be run on most popular databases, so I
> would llike to make it as DB agnostic as possible.
hi chris
whoa, coincidence? today's tipworld sql tip was about this very topic --
http://www.topica.com/lists/tipworld-sql/read/message.html?mid=1602211537&s
ort=d&start=410
the same solution is presented in the following evolt article --
http://evolt.org/article/TopTenSQL/18/131/evolt.org
which is getting a bit long in the tooth now =o)
i think the TOP keyword is actually standard SQL3 but as you point out it
may not be supported by all databases
rudy.ca
p.s. i love the term "database agnostic"
More information about the thelist
mailing list