Solved

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

Posted on 2011-09-25
4
213 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Entering multiple email addresses 4 65
problem with finding cfcomponent on cfselect bind 7 77
Coldfusion get content of HTML table 8 147
Coldfusion - query to list question 3 27
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 …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now