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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:22:28+00:00 2026-06-15T04:22:28+00:00

i have not ideal what happen on this. this is working fine SELECT SUM(LAMT)AS

  • 0

i have not ideal what happen on this.

this is working fine

SELECT 
SUM(LAMT)AS SUMAMT, 
COUNT(LAMT)AS CNT, 
IFNULL(LSUBDT,(CURDATE()-INTERVAL 9999 DAY))AS MXDT 
FROM product1 
WHERE LSUBBY IN (12,15,17,13,14,16) AND RECST=1 ORDER BY LSUBDT

it return me (which is fineZ)
SUMAMT > 645746.00
CNT > 4
MXDT > 2012-11-14 15:56:56

BUT
when i using MAX(IFNULL(LSUBDT,(CURDATE()-INTERVAL 9999 DAY)))AS MXDT
it return me
MXDT > 323031322d31312d32332030353a30323a3037

WHY? i cant use it to do compare in php when using strtotime

1). what’s wrong with the sql MAX()?
2). Any alternative beside MAX()? i want get the latest DATETIME.
3). can some where some how php CONVERT it back to 2012-11-14 15:56:56 format then i continue in php compare later

By the way
4). the return result of MXDT > 2012-11-14 15:56:56 also is not correct coz in the database the latest datetime is 2012-11-24 5:36:25, if i remove the sum and the count then it return me correctly.

thanks

  • 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-15T04:22:29+00:00Added an answer on June 15, 2026 at 4:22 am

    Try this:

    SELECT SUM(SUMAMT)AS SUMAMT, SUM(CNT)AS CNT, MAX(MXDT) AS MXDT 
    from (SELECT SUM(LAMT)AS SUMAMT, COUNT(LAMT)AS CNT, 
                 IFNULL(LSUBDT,(CURDATE()-INTERVAL 9999 DAY)) AS MXDT 
          FROM (SELECT LAMT, LSUBDT FROM product1 
                WHERE LSUBBY IN (12,15,17,13,14,16) AND RECST=1 ORDER BY LSUBDT DESC 
         ) AS A GROUP BY LSUBDT
    ) AS B
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some basic idea on how to do this task, but I'm not
Any idea why the following code is not working mysql credentials are correct, have
we've been getting this error lately and have no idea why, we are not
I have not had to do something like this in the past and am
I have a rails app that is working fine except for one thing. When
Okay, so I have this script which works fine with IE but won't work
We have developed a set of crystal reports (not my idea) that are to
I have no idea why but the contentherewrap div does not show fully when
I've not read the Modern C++ Design book but have found the idea of
I get the following Nhiberante error, but have no idea why: could not execute

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.