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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:46:41+00:00 2026-06-07T01:46:41+00:00

Error: ORA-00937: Not a single-group group function Query: select count(*) todas, sum(case when i.prioridade

  • 0

Error: ORA-00937: Not a single-group group function

Query:

    select count(*) todas,
       sum(case when i.prioridade = 1 then 1 else 0 end) urgente,
       sum(case when i.prioridade = 2 then 1 else 0 end) alta,
       sum(case when i.prioridade = 3 then 1 else 0 end) normal,
       sum(case when i.prioridade = 4 then 1 else 0 end) baixa,
       (select count(*)
        from GMITEMOS i 
        inner join GMCTLSLA c  on c.os = i.cd_numero_os and c.item = i.item
        where i.situacao in ('A', 'I', 'P')
           and c.ordem = 99999
           ) naoAvaliados,
       sum(case when i.situacao = 'P' then 1 else 0 end) pendentes,
       sum(case when i.situacao = 'A' or i.situacao = 'I' then 1 else 0 end) iniciados
from GMITEMOS i 
where i.situacao in ('A', 'I', 'P')
   and  exists (select 1 
               from GMCTLSLA c 
               where c.os = i.cd_numero_os 
                  and c.item = i.item)

The error is ocurring here:

(select count(*)
        from GMITEMOS i 
        inner join GMCTLSLA c  on c.os = i.cd_numero_os and c.item = i.item
        where i.situacao in ('A', 'I', 'P')
           and c.ordem = 99999
           ) naoAvaliados

Can someone tell why is it happening?

  • 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-07T01:46:42+00:00Added an answer on June 7, 2026 at 1:46 am

    You may have fixed it with max but that’s not why it’s happening and is a little bit hacky. Your problem is that your sub-query, which translates into a single column is not an aggregate query, min, max, sum etc and so needs to be included in a group by clause. You fixed this by wrapping it in max as the maximum of a single value will always be constant.

    However, as your sub-query is, itself, an analytic query and will only ever return one row the obvious thing to do is to use a cartesian join to add it to your query. In the explicit join syntax this is known as the cross join.

    select count(*) todas
         , sum(case when i.prioridade = 1 then 1 else 0 end) urgente
         , sum(case when i.prioridade = 2 then 1 else 0 end) alta
         , sum(case when i.prioridade = 3 then 1 else 0 end) normal
         , sum(case when i.prioridade = 4 then 1 else 0 end) baixa
         , naoAvaliados
         , sum(case when i.situacao = 'P' then 1 else 0 end) pendentes
         , sum(case when i.situacao = 'A' or i.situacao = 'I' then 1 else 0 end) iniciados
      from GMITEMOS i 
     cross join (select count(*) as naoAvaliados
                   from GMITEMOS j
                  inner join GMCTLSLA k
                     on k.os = j.cd_numero_os 
                    and k.item = j.item
                  where j.situacao in ('A', 'I', 'P')
                    and k.ordem = 99999
                        )
     where i.situacao in ('A', 'I', 'P')
       and exists (select 1 
                     from GMCTLSLA c 
                    where c.os = i.cd_numero_os 
                      and c.item = i.item
                          )
    

    The cartesian join has a bad reputation as it multiples the number of rows on one side of the join by the number of rows on the other. It does, however, have it’s uses, especially in this sort of case.

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

Sidebar

Related Questions

fail statement:Error: ORA-00979: not a GROUP BY expression select org_division.name , org_department.name , org_surveylog.division_code
The follow query is returning an error at column 143: ORA-00934: group function is
Query's throwing an ORA-00907 Error when I try to paste a list of values
I get error: ORA-06575: Package or function GET_CONC_NAMES is in an invalid state When
Recently I had to write an oracle function, and the error ora-06575 popped up
I got the following error of Oracle, ORA-25226: dequeue failed, queue string.string is not
I'm getting an error while executing following select query: ResultSet rs = St.executeQuery(select *
I'm attempting to run this Oracle query... SELECT COUNT(*) as total, q1 FROM exit_responses
I am getting the error ORA-00936: missing expression on the following SQL statement: SELECT
I'm getting an error message of ORA-00936: missing expression at the very start of

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.