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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:24:10+00:00 2026-05-24T14:24:10+00:00

I have a table in an RDBMS which logs the user logins. A user

  • 0

I have a table in an RDBMS which logs the user logins.
A user can login to the system many times during the day and my application logs these logins.

The problem is, I need to write a query which gets the first login per day of the users between desired dates like 2011-04-21 to 2011-07-08

Login Log Table

userID  Login Date 
guess   2011-04-21 16:46:46.000
Admin   2011-05-03 17:32:15.000
guess   2011-05-05 15:48:54.000
guess   2011-06-01 14:14:50.000
guess   2011-06-01 14:23:18.000
my_user 2011-07-08 15:42:20.000
guess   2011-07-08 16:15:08.000
guess   2011-07-08 16:19:14.000
my_user 2011-07-08 16:36:45.000
my_user 2011-07-08 16:37:41.000
my_user 2011-07-08 16:42:21.000

Query Should give result like below (The first login date/time for each day)

UserID  First_Login_Date
guess   2011-04-21 16:46:46.000
Admin   2011-05-03 17:32:15.000
guess   2011-05-05 15:48:54.000
guess   2011-06-01 14:14:50.000
my_user 2011-07-08 15:42:20.000
guess   2011-07-08 16:15:08.000
  • 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-24T14:24:11+00:00Added an answer on May 24, 2026 at 2:24 pm
    SELECT UserID, MIN(Login_Date) as First_Login_Date
    FROM Login
    WHERE Login_Date BETWEEN inputStartDate AND inputEndDate
    GROUP BY UserID, YEAR(Login_Date), MONTH(Login_Date), DAY(Login_Date)
    

    Edited to group BY user AND day. Your question was not specific that you wanted the first login of each user for each day they logged in. I’m positive this solution works for MS SQL Server 2005+, if you need a different RDBMS, comment.

    If you’d like more options for grouping by a certain date, feel free to look at this article.

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

Sidebar

Related Questions

I have table rows of data in html being filled from a CGI application.
I am developing an application which doesn't have large requirements for data storage. I
I am working on a system, which will run on GAE, which will have
I'm looking to model in an RDBMS a meeting which has several proposed times,
In most RDBMS, the meta-model is self contained, which means that I can find
suppose that I have this RDBM table ( Entity-attribute-value_model ): col1: entityID col2: attributeName
I have table inside a div tab. The table has 40 rows in it
I have table with 50 entries (users with such details like Name Surname Location
I have table with some fields that the value will be 1 0. This
i have table structure with 3 colums (column1, column2, column3) and i want to

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.