[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 --


the same solution is presented in the following evolt article --


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


p.s. i love the term "database agnostic"

More information about the thelist mailing list