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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:09:04+00:00 2026-06-08T22:09:04+00:00

I have a query: SELECT MIN(stat_md5) AS stat_md5 FROM (select * from ( mem_stat

  • 0

I have a query:

SELECT MIN(stat_md5) AS stat_md5 
FROM 
     (select * from ( mem_stat NATURAL LEFT OUTER JOIN host ))
GROUP BY stat_md5;

This query is running fine in SQLite version 3.4.2, but when I upgraded to version 3.7.11, it is giving following error:

SQL error: aggregate functions are not allowed in the GROUP BY clause

If I remove MIN() or GROUP BY or AS from the query, then its working fine in version 3.7.11.

It means following variants of query are working fine:

SELECT MIN(stat_md5) AS stat_md5 
FROM 
     (select * from ( mem_stat NATURAL LEFT OUTER JOIN host ))


SELECT MIN(stat_md5) 
FROM 
     (select * from ( mem_stat NATURAL LEFT OUTER JOIN host ))
GROUP BY stat_md5;


SELECT stat_md5 
FROM 
     (select * from ( mem_stat NATURAL LEFT OUTER JOIN host ))
GROUP BY stat_md5;

Can someone please explain why is it giving error in version 3.7.11 and workaround for it.

UPDTATE:

This is the original query.

SELECT 
      stat_day, obs_day, stat_week, obs_week, 
      NULL AS stat_cputotal, stat_memfree, stat_md5,
      stat_month, obs_month, stat_type, stat_memused, stat_10min, obs_10min, 
      NULL AS stat_cpusystem, stat_epoch, obs_epoch, stat_30day, obs_30day, 
      stat_idx, obs_idx, NULL AS stat_cpuidle, stat_memtotal, stat_qtr, obs_qtr,
      NULL AS stat_cpuuser, stat_hour, obs_hour, obs_10min, stat_10min, 
      obs_30day,stat_30day, obs_day, stat_day, obs_epoch, stat_epoch, obs_hour,
      stat_hour, obs_idx, stat_idx, obs_month, stat_month, obs_qtr, stat_qtr, 
      obs_week, stat_week, serial_num, NULL AS dputil_cpuid, NULL AS wms_pk 
      FROM (
       (
       SELECT stat_qtr, obs_qtr, stat_qtr AS cus_qtr, stat_qtr AS crash_qtr, 
              stat_qtr AS evt_qtr, stat_30day, obs_30day, stat_30day AS cus_30day, 
              stat_30day AS crash_30day, stat_30day AS evt_30day, stat_month, 
              obs_month, stat_month AS cus_month, stat_month AS crash_month, 
              stat_month AS evt_month, stat_week, obs_week, stat_week AS cus_week, 
              stat_week AS crash_week, stat_week AS evt_week, stat_day, obs_day, 
              stat_day AS cus_day, stat_day AS crash_day, stat_day AS evt_day, 
              stat_hour, obs_hour, stat_hour AS cus_hour, stat_hour AS crash_hour, 
              stat_hour AS evt_hour, stat_10min, obs_10min, stat_10min AS cus_10min, 
              stat_10min AS crash_10min, stat_10min AS evt_10min, stat_epoch, 
              obs_epoch, stat_epoch AS cus_epoch, stat_epoch AS crash_epoch, 
              stat_epoch AS evt_epoch, stat_idx, obs_idx, stat_idx AS cus_idx, 
              stat_idx AS crash_idx, stat_idx AS evt_idx, obs_10min, obs_30day, 
              obs_day, obs_epoch, obs_hour, obs_idx, obs_month, obs_qtr, obs_week, 
              serial_num, stat_md5, MIN(stat_memfree) AS stat_memfree, MIN(stat_md5) 
              AS stat_md5, MIN(stat_type) AS stat_type, MIN(stat_memused) AS 
              stat_memused, MIN(stat_memtotal) AS stat_memtotal 
              FROM 
                   (select * from ( mem_stat NATURAL LEFT OUTER JOIN host )) 
                    GROUP BY 
                            stat_qtr, stat_30day, stat_month, stat_week, 
                            stat_day, stat_hour, stat_10min, stat_epoch, 
                            stat_idx, obs_10min,obs_30day, obs_day, obs_epoch, 
                            obs_hour, obs_idx, obs_month, obs_qtr, obs_week, 
                            serial_num, stat_md5
                   ))
  • 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-08T22:09:05+00:00Added an answer on June 8, 2026 at 10:09 pm

    , stat_md5, MIN(stat_memfree) AS stat_memfree, MIN(stat_md5) AS stat_md5,

    stat_md5 is twice on the SELECT list: once alone and once as the alias of a MIN(). 3.4.2 must have used the first one and 3.7.11 must be using the second.

    Grouping by an aggregated field makes no sense, so the error is right.

    Just change the alias of the second time to something like AS min_stat_md5 and it will work fine. Having two fields with the same name on a SELECT is bad idea in any case.

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

Sidebar

Related Questions

We have the query: SELECT ID, MIN(SQRT(POW((100-x),2)) + POW((150-y),2)) AS distance FROM cabstands GROUP
I have this query select date(fecha) as day, min(num) as mi from myTable where
I have a query: select min(timestamp) from table This table has 60+million rows, and
I have this MySQL query that I'd like to optimize: SELECT min(`topic_id`) FROM `gallery_topics`
I have a query SELECT cd.signoffdate, min(cmp.dsignoff) as dsignoff FROM clients AS c LEFT
I have a query: select substr(name,7,50) as location, points,sum(if (p1=r1,10,-10))as total from dq.data group
I have this query: SELECT * From checkfinale where AssociateID = 51 AND `CompletedDate`
I have a query as follows: WITH CTE AS ( SELECT MIN(att.Date) [minDate] FROM
I have the following query: SELECT a.topicID, d.catalogFileID, d.catalogFileExtension, a.sortorder FROM catalog_topics a LEFT
I have this query so far: SELECT `p`.`id`, cp.pattern_category_id, `p`.`title`, `p`.`filename`, p.precedence FROM (`patterns`

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.