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

  • Home
  • SEARCH
  • 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 7785557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:16:30+00:00 2026-06-01T20:16:30+00:00

I have a table abc where i store timestamp having multiple records let suppose

  • 0

I have a table “abc” where i store timestamp having multiple records let suppose

1334034000  Date:10-April-2012
1334126289  Date:11-April-2012 
1334291399  Date:13-April-2012

I want to build a sql query where I can find at first attempt the records having last two day values and so second time the next two days . . .

Example:

Select *,dayofmonth(FROM_UNIXTIME(i_created)) from notes
where dayofmonth(FROM_UNIXTIME(i_created)) > dayofmonth(FROM_UNIXTIME(i_created)) -2
order by dayofmonth(FROM_UNIXTIME(i_created))

this query returns all the records date wise but we need very most two days record.

Please suggest accordingly.
Thanks in advance

Edited:

If today is 13 April and our table has max day 10, 9, 8, . . . april then we have to show the 10, 9 April and his last date records

  • 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-01T20:16:32+00:00Added an answer on June 1, 2026 at 8:16 pm

    Try this query –

    SELECT t1.* FROM table t1
      JOIN (SELECT date FROM table GROUP BY date DESC LIMIT 2) t2
        ON t1.date = t2.date
    

    It will show all records with date = ’11-April-2012′ and ’13-April-2012′.

    Is this what you want?


    Edited:

    SELECT
      t1.*, t2.date
    FROM
      notes t1
    JOIN (SELECT
            DATE(FROM_UNIXTIME(i_created)) date
          FROM
            notes
          GROUP BY
            date DESC
          LIMIT
            2
      ) t2
    ON
      DATE(FROM_UNIXTIME(t1.i_created)) = t2.date
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table abc with a field datetime_abc type-> DATETIME in mysql. and
I have a table as Name(String) fromRange(int) toRange(int) abc 15160 15180 bhy 12510 12515
I have the following table (points): recno uid uname points ============================ 1 a abc
I'm trying to store XML in SQL 2005. I have a very simple table
Suppose a database table containing properties of some elements: Table Element (let's say 1
(Note: this is for MS SQL Server) Say you have a table ABC with
Hi I have 3 table xyz abc and pqr ,structure of xyz and abc
I have a table called Employee Eno ename AttributeValue AttributeName 1 aa a123 abc
I have a table, EmpDetail , with three columns: EMP_NAME DETAIL_ID DETAIL ---------------------------------- ABC
I have a table code_prices that looks something like this: CODE | DATE |

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.