30 records is exactly as you had the code. You did it better than some may have
as using top inside the code is better than using maxrows in the CFQUERY. More
exact to the DB.


> Thanks Michael. I figured out I was having some type of mysterious brain
> lapse shortly after posting this. :) I was thinking 30 records rather
> than 30 days.
> MW
>
> -----Original Message-----
> From: Michael Dinowitz [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 27, 2003 3:05 PM
> To: SQL
> Subject: Get last n Records
>
>
> This will get the last 30 records in the DB. This will only work the way
> you want it if there is one record going in per day every day.
> Otherwise, you'll just be getting the last 30. If you want to be sure on
> the dates, you'll have to query on a date field of some sort with a
> datediff() function in SQL.
> where datediff('d', now(), datefield) LT 30
> will get you all the records that are within 30 days of the current day.
>
> >Hi,
> >
> >I am trying to help someone with a SQL query and was wondering if
> >someone here could help me with my reasoning. The goal is to get all
> >records entered within the last 30 days that meet one specific
> >criterion. Would something like this work?
> >
> >
> >SELECT  Top 30 *
> >FROM myTable
> >WHERE someCol = 'value'
> >ORDER BY someCol DESC
> >
> >Best regards,
> >Michael Wilson <mailto:[EMAIL PROTECTED]>  - IQMax
> ><http://www.iqmax.com/>  - Software Engineer
> >
> >
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

                        

Reply via email to