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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:02:38+00:00 2026-06-15T01:02:38+00:00

I have a table containing the logging of a web app which tracks when

  • 0

I have a table containing the logging of a web app which tracks when people log in. An example of my table is:

| user_id | date_time        |
+---------+------------------+
|    0033 | 2012-11-22 10:33 | <- first login of 0033 on 2012-11-22
|    0034 | 2012-11-22 10:38 | <- first login of 0034 on 2012-11-22
|    0052 | 2012-11-22 10:43 | <- first login of 0052 on 2012-11-22
|    0052 | 2012-11-23 09:23 |
|    0066 | 2012-11-23 15:58 | <- first login of 0066 on 2012-11-23
|    0033 | 2012-11-23 16:14 |

The thing I want is a table with the amount of people that logged in for the first time on each date, i.e.:

| count | date       |
+-------+------------+
|     3 | 2012-11-22 | <- there were 3 users that logged in for the first time on 2012-11-22
|     1 | 2012-11-23 |

I know I can get the date only, by doing

SELECT DATE(`date_time`) AS `date`
FROM `logging`
GROUP BY `date`
ORDER BY `date` ASC

I would like to get the second table in one query, I know it’s possible, I just don’t know how. Thanks in advance

  • 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-15T01:02:43+00:00Added an answer on June 15, 2026 at 1:02 am

    You can use an uncorrelated subquery to get the first login date for every user and then group those dates together to get the number of first logins per day.

    SELECT dd, COUNT(*)
    FROM (SELECT MIN(DATE(`date_time`)) AS dd
        FROM `logging`
        GROUP BY `user_id`) a
    GROUP BY dd
    ORDER BY dd;
    

    Demo

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

Sidebar

Related Questions

I have a table containing events which happen in my application like people logging
I have a table containing the following data periodID periostart periodend 1 01-01-2012 10-01-2012
I have a table containing data which I do not want to wrap onto
I have a table containing user input which needs to be optimized. I have
I have a table containing hundreds of columns many of which are null, and
I have a table containing log entries for a single week for about a
I have a table containing a series of names, events and dates. I've created
I have a table containing the results of games played. I have another table
I have a table containing data about some users. Many of them use our
I have a table containing reports and the date/time they were created. I'd like

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.