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 784011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:38:36+00:00 2026-05-14T20:38:36+00:00

Hello EVery I am new to SQl. query to result in the following records.

  • 0

Hello EVery I am new to SQl. query to result in the following records.

I have a table with records as

c1  c2            c3                  c4    c5   c6

1  John         2.3.2010 12:09:54     4     7    99        
2  mike         2.3.2010 13:09:59     8     6    88   
3  ahmad         2.3.2010 13:09:59     1     9    19   


4  Jim        23.3.2010 16:35:14      4     5    99   
5  run        23.3.2010 12:09:54      3     8    12 

I want to fecth only records.
i.e only 1 latest record per day. If both of them happen at the same time, sort by C1.so in 1&3 it should fetch 3.

3  ahmad         2.3.2010 14:09:59     1     9    19   
4  Jim        23.3.2010 16:35:14      4     5    99

I have got a new problem in this.
If i filter the records based on conditions the last record is missing. I tried many ways but still it is failing. Here update_log is my table.

SELECT * FROM update_log t1 
WHERE (t1.c3) = 
(
    SELECT MAX(t2.c3) 
    FROM update_log t2 
    WHERE DATEDIFF(dd,t2.c3, t1.c3) = 0 
)
and t1.c3 > '02.03.2010' and t1.modified_at <= '22.03.2010' 

ORDER BY t1.c3 ASC. But i am not able to retrieve the record

4  Jim        23.3.2010 16:35:14      4     5    99

I dont know this query results in only

  3  ahmad         2.3.2010 14:09:59     1     9    19   

The format of the column c3 is datetime. I am pumping the data into the column as
using $date = date("d.m.Y H:i",time()); — simple date fetch of today.

Another query that i tried for the same purpose.

select * from (select convert(varchar(10), c3,104) as date, max(c3) as max_date, max(c1) as Nr from update_log group by convert(varchar(10), c3,104)) as t2 inner join update_log as t1 on (t2.max_date = t1.c3 and convert(varchar(10), c3,104) = date and t1.[c1]= Nr) WHERE t1.c3 >= '02.03.2010' and t1.c3 <= '16.04.2010' . I even tried this way..the same error last record is not coming..

  • 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-05-14T20:38:37+00:00Added an answer on May 14, 2026 at 8:38 pm

    OK, Now i understood. actually i wrote the query for the same purpose this way.

    select * from #temp 
    select * from
    (select max(c1) as nr from 
    (select convert(varchar(10), c3,104) as date, max(c3) as max_date
     from #temp  where 
     convert(varchar(10),c3,104) >=  '02.02.2010' and 
    convert(varchar(10),c3,104) <= '23.02.2010'
    group by convert(varchar(10), c3,104))
     as t2 inner join #temp as t1 on (t2.max_date = t1.c3 and 
    convert(varchar(10), c3,104) = date)  
    group by convert(varchar(10),max_date,104))
    as t3 inner join #temp as t4 on (t3.nr = t4.c1 )
    

    If i change these 2 lines to c3 >= ‘02.02.2010’ and
    c3 <= ‘24.02.2010’. It is working fine. but the query that i have posted is not able to filter the records properly based on dates.

    I want to know where i went to wrong to enhance my knoweldge rather than just copying ur query:-)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello every one I have wrote a simple code in html5 in which I
Hello I have a table on which I have denied SELECT privs to a
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
Hello every one i have strange bug with dropdownlist on one of the pages!
I use the new wordpress plugin, google xml sitemap. Hello, lets say I have
I have the following : Runnable done = new Runnable() { public void run()
Hello everyone and thank you for your answers and comments. I have a table
hello every one i want to ask that i have read that we can
I have a SQL-table with three columns: Id, English and Norwegian. Id is the
Hello every I'm new in iPhone development I want to animate text word by

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.