Solved

how to select only the single, most recent data record?

Posted on 2011-09-25
4
215 Views
Last Modified: 2012-05-12
ColdFusion 9
SQL Server 2005

I need to query a data table and get back only the single, most recent data record. How can I do that?

<cfquery name="getmostrecentblogpost" datasource="#application.datasource#">
SELECT blogID, blogTitle, blogExcerpt, blogAuthor, blogDate
FROM TIRBlog
WHERE blogDate (is the most recent date)
</cfquery>

Open in new window


I've looked around, but no solution seems to exactly fit my requirement. Thank you as always.

Eric
0
Comment
Question by:Eric Bourland
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
sajayc earned 500 total points
ID: 36596584
Hi,
You can modify your query so that the results are in date order with most recent first and then use the top 1 to only return 1 record.

SELECT top 1 blogID, blogTitle, blogExcerpt, blogAuthor, blogDate
FROM TIRBlog
order by blogDate

Does that do what you want?
0
 
LVL 3

Author Comment

by:Eric Bourland
ID: 36596586
I'll try that! hang on....
0
 
LVL 3

Author Closing Comment

by:Eric Bourland
ID: 36596594
That worked very well. Thank you,sajayc.
0
 
LVL 3

Expert Comment

by:sajayc
ID: 36596597
Your welcome!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question