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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:52:42+00:00 2026-05-28T02:52:42+00:00

I am working on a project where I need to get the minimum and

  • 0

I am working on a project where I need to get the minimum and maximum date from a database as well substringing the first part of a field up to a character and grouping by this field. So basically in the database I have

2012-01-01 Unknown username/password attempted to login. User: admin

2012-01-01 Failed to add user account. MySQL Error: certain my sql
error Unknown

2012-01-02 Failed to add user account. MySQL Error: certain my sql
error Unknown

2012-01-04 Unknown username/password attempted to login. User:
administrator

Below is the query that I am using which is working without showing the date

SELECT ala_type, partMsg, 
wholeMsg, ala_level, ala_page, COUNT(wholeMsg) AS msgCount FROM
(
SELECT ala_type, SUBSTRING_INDEX(ala_message, ':', 1) AS partMsg, ala_message AS wholeMsg,
ala_level, ala_page FROM alarms a) p
GROUP BY partMsg

This bit is grouping correctly as expected but if I try to add a min(date_field) it then only shows one record.

Below is the query that I have tried

SELECT ala_date, min(ala_date), max(ala_date), ala_type, partMsg,
wholeMsg, ala_level, ala_page, COUNT(wholeMsg) AS msgCount FROM (
SELECT ala_date, min(ala_date), max(ala_date), ala_type,
SUBSTRING_INDEX(ala_message, ‘:’, 1) AS partMsg, ala_message AS
wholeMsg, ala_level, ala_page FROM alarms a) p GROUP BY partMsg

If I don’t put ala_date in the second statement and just have min(ala_date) it says that it can’t find the field ala_date. However, when I run the query I am only getting one record and I would have expected to see the following

2012-01-01 2012-01-04 Unknown username/password attempted to login.User: 2

2012-01-01 2012-01-02 Failed to add user account. MySQL Error: > certain mysql error 2

The 2 and the end of the expected result is the count how many times the message occurred.

What I am actually getting is:

2012-01-01 2012-01-01 2012-01-01 Failed to add user account… 1

It is now only showing 1 record and the min and max only are the same and the count is 1 instead of 2.

What could I do to get what I am expecting to get.

Thanks for any help you can provide.

  • 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-28T02:52:43+00:00Added an answer on May 28, 2026 at 2:52 am

    You would do something like (my mysql is rusty) but the theoiry is sound.

    Select SomeDate,SomeMessage From SomeTable
    inner join (
    Select Min(SomeDate) as SomeDate From SomeTable) earliest
    On earliestDate.SomeDate = SomeTable.SomeDate
    

    ie find the minimum date for for each group then join back to the original table to find the records that were also on that date.

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

Sidebar

Related Questions

I am working on my android project with SQLite database. I need to get
i am working on a magento project and i need to get the value
I have a project I need to be working on from two different computers,
I'm working on a project where I need to find which functions get called
I'm working on a side project and at its core, I need to get
I am working on a spring 2.5.4 project, where I need to get an
I've got a project that I need to get working with 3 compilers (Borland,
I am working a project where I need to generate a series of classes
I'm working on a project were we need more performance. Over time we've continued
I'm working on a project where I need the following. WCF service on the

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.