Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-25
4
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
sajayc earned 2000 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 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