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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:33:31+00:00 2026-06-17T23:33:31+00:00

Not very proficient with SQL. I am trying to get username, count number of

  • 0

Not very proficient with SQL. I am trying to get username, count number of login attempts and the last date of login attempt from a database table. The table schema is something like this:

username character varying,
logindate timestamp,
result character varying,
clientip character varying

I was able to get the username and number of attempts from the following query:

SELECT USERNAME, COUNT(USERNAME) FROM LOGINTABLE GROUP BY USERNAME

Is it possible to get the date for last login from the same query? Please advice.

DB Used: POSTGRESQL

  • 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-17T23:33:32+00:00Added an answer on June 17, 2026 at 11:33 pm

    yes, use MAX()

    SELECT  USERNAME, 
            COUNT(USERNAME) AS TotalCount, 
            MAX(logindate) AS LastLoginDate
    FROM    LOGINTABLE 
    GROUP   BY USERNAME
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a basic question but I'm not very proficient in SQL Server.
I am not very experienced in SQL. I am using SQL Server 2008, and
I have a not-very-normalized MySQL table with the following values: customer_ID | date |
Hi there not very proficient in coding. I have #content fading out and in
I'm not very proficient with AJAX but by all accounts I think this should
It should be noted that I am not very proficient at using Firebug, but
Im not proficient in JS myself very much, so it would probably take me
I am not so proficient in TSql as of now (writing since last 4/5
I am not very proficient in perl, awk, or sed and I have been
I am not very proficient in Mac OS X programming, but I am working

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.