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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:18:39+00:00 2026-05-31T02:18:39+00:00

How to select the first element of each day in a month with mysql

  • 0

How to select the first element of each day in a month with mysql query ?

I have table with offers – startdate, so i can check for each day,month,year i’m getting the element but, i’m wondering how to get only the first element in each day of some month ?

  • 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-31T02:18:40+00:00Added an answer on May 31, 2026 at 2:18 am

    Assume the following

    • Table is called mytable
    • Table has id as primary key
    • Table has dt as datatime
    • You want the first id of everyday in February 2012

    Try this:

    SELECT B.id FROM
    (
        SELECT DATE(dt) date_dt,MIN(dt) dt
        FROM mytable
        WHERE dt >= '2012-02-01 00:00:00'
        AND   dt < '2012-03-01 00:00:00'
        GROUP BY DATE(dt)
    ) A
    LEFT JOIN mytable B USING (dt);
    

    If any dt has multiple B.id values try this:

    SELECT dt,MIN(id) id
    (
        SELECT B.id,B.dt FROM
        (
            SELECT DATE(dt) date_dt,MIN(dt) dt
            FROM mytable
            WHERE dt >= '2012-02-01 00:00:00'
            AND   dt < '2012-03-01 00:00:00'
            GROUP BY DATE(dt)
        ) A
        LEFT JOIN mytable B USING (dt)
    ) AA GROUP BY dt;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table in MySql db: After running this query: SELECT score, count(*)
I have an array char[] Select = {'A','B','C','D','E','F','G','H','I','J'} and each element in this array
I have two select-boxes, each of them is in span element with specific id.
I have first: select url from urls where site = '$value' order by url
I can select the first item in the div using $('.class:first') Now since I
How can I select the first 4 rows of a data.frame : Weight Response
This is my second day with Jquery and I have a dropdown-list each time
I need to check if each element in second list has 3 times more
I have a handlebars.js template, just like this: {{externalValue}} <select name=test> {{#each myCollection}} <option
I have a select box that should be populated only when clicked. The query

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.