Your ORDER BY field(s) should determine which records are returned; it your
example, you should be getting the 2 records with the highest end_date
value.

If you order by ID, you'll get 2 records with the lowest (sorted ascending)
or highest (sorted descending) ID.

Is end_date in fact a date field?  Or is it perhaps text?

-----Original Message-----
From: W Luke [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 4:00 PM
To: CF-Talk
Subject: Re: TOP function not performing



> try the same query with ORDER BY clauses in both the query and it's
> sub-query, if there is a sub-query.

ORDER BY - should I be ordering by ID in this case?


SELECT TOP 2 ID,Left(subject,20) AS subjects,end_date
FROM advert_details
ORDER BY end_date DESC

Will
--
[EMAIL PROTECTED] -=- www.lukrative.com
Local-Advertising -=- www.localbounty.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to