Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9034603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:31:41+00:00 2026-06-16T08:31:41+00:00

I have SQL table in SQL server 2008, and I want to get latest

  • 0

I have SQL table in SQL server 2008, and I want to get latest record which depends on its date.

E.g. Lets say I have records with some column and a Date column which contain the date of creation of record.
Lets sat the date column contains following dates. 22-Dec, 23-Dec, 24-Dec, 25,Dec, 26-Dec.

Now , I want to fetch the record which is less than 25 Dec, but I want the latest date record, If I write the query

select * from Table where CreateDate < '25-Dec-2012' 

then It will return 3 records but I want the latest record from them i.e. 24 Dec record

How to do it ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:31:42+00:00Added an answer on June 16, 2026 at 8:31 am

    You should add TOP 1 to your query, and order it in reverse of its natural order to get your last record first. Assuming that the default order is by CreateDate in ascending order, the ORDER BY CreateDate DESC should do the trick:

    SELECT TOP 1 *
    FROM Table
    WHERE CreateDate < '25-Dec-2012' 
    ORDER BY CreateDate DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have SQL server 2008 R2. I want to get column name and table
I use SQL Server 2008 R2 and have a table that I want no
In SQL Server 2008: I have one table, and I want to do something
I am using SQL Server 2008. I have a Student table in which there
Let's say I have some data, either in a SQL Server 2008 table or
We have a SQL server 2008 and one of the tables, say table A
I have an integer column(not null) in a sql server 2008 database/table, I want
Am using Sql Server 2008, I have a column named Date in my table,
I am using SQL Server 2008. I have a table A which accepts many
I have SQL Server 2008 with a table called ProductCategories designed like this: Id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.