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

  • Home
  • SEARCH
  • 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 4626516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:25:56+00:00 2026-05-22T03:25:56+00:00

I am working with PL/SQL (Oracle). I have written queries before, but I’m not

  • 0

I am working with PL/SQL (Oracle).
I have written queries before, but I’m not sure what is wrong with this query. The error I am getting is this:

[Error] Execution (942: 41):
ORA-00979: not a GROUP BY expression.

The highlighted text is: the first TRIM function in the case statement. I know that I can’t put this case statement in the Group By clause because I am aggregating here (using the sum function). Is there something I am not understanding??

SELECT 
T.PLANNAME, 
M.CLASS, 
M.BRAND_OR_GENERIC, 
T.PROCEDURECODE, 
M.BRAND_NAME, 
M.GENERIC_NAME, 
CASE 
WHEN (TRIM(PLANNAME) = 'XXXX' AND TRIM(LOBDESC) = 'COMMERCIAL') THEN ROUND((SUM(ALLOWEDAMT)/160000)*1000000, 2)
WHEN (TRIM(PLANNAME) = 'XXXX' AND TRIM(LOBDESC) = 'MEDICARE') THEN ROUND((SUM(ALLOWEDAMT)/14000)*1000000, 2)
WHEN (TRIM(PLANNAME) = 'YYYY' AND TRIM(LOBDESC) = 'COMMERCIAL') THEN ROUND((SUM(ALLOWEDAMT)/1800000)*1000000, 2)
WHEN (TRIM(PLANNAME) = 'YYYY' AND TRIM(LOBDESC) = 'MEDICARE') THEN ROUND((SUM(ALLOWEDAMT)/35000)*1000000, 2)
WHEN (TRIM(PLANNAME) LIKE 'ZZZZ%' AND TRIM(LOBDESC) = 'COMMERCIAL') THEN ROUND((SUM(ALLOWEDAMT)/1200462)*1000000, 2)
WHEN (TRIM(PLANNAME) LIKE 'ZZZZ%' AND TRIM(LOBDESC) = 'MEDICARE') THEN ROUND((SUM(ALLOWEDAMT)/235000)*1000000, 2)
WHEN (TRIM(PLANNAME) = 'AAAA' AND TRIM(LOBDESC) = 'COMMERCIAL') THEN ROUND((SUM(ALLOWEDAMT)/200000)*1000000, 2)
WHEN (TRIM(PLANNAME) = 'BBBB' AND TRIM(LOBDESC) = 'MEDICAID') THEN ROUND((SUM(ALLOWEDAMT)/147000)*1000000, 2)
END As AllowedPerMM,
SUM(T.ALLOWEDAMT) As SumOfALLOWEDAMT 


FROM FIN.TR_2011 T
LEFT JOIN FIN.TR_REFERENCE M ON T.PROCEDURECODE = M.PROCEDURECODE

WHERE 
T.PROCEDURECODE IS NOT NULL AND  
(T.PROCEDURECODE <> '0' or T.PROCEDURECODE <> 0)  AND 

(T.PROCEDURECODE Like 'J%' OR 
T.PROCEDURECODE Like 'C9%' OR
T.PROCEDURECODE Like 'S0%' OR
T.PROCEDURECODE Like 'Q%' OR 
T.PROCEDURECODE = '90378' OR 
T.PROCEDURECODE IN ( 
'J9171', 'J9265', 'J9264', 
'J2430', 'J3487',
'J9000', 'J9001') OR
M.THERAPEUTIC_CLASS IN ('RA')
) AND 
TRIM(T.YEAR) IN ('2010')

GROUP BY 
T.PLANNAME, 
M.CLASS, 
M.BRAND_OR_GENERIC, 
T.PROCEDURECODE, 
M.BRAND_NAME, 
M.GENERIC_NAME

ORDER BY SumOfALLOWEDAMT DESC ; 
  • 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-22T03:25:56+00:00Added an answer on May 22, 2026 at 3:25 am

    Your problem is that you are trying to access a non aggragate (LOBDESC) in a grouping context. You have two options, choose the one which makes most sense:

    • Add LOBDESC to GROUP BY
    • Use an aggregate function, i.e. MAX(LOBDESC)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that contains a tree in oracle. MY_TABLE node_id parent_id How
I have an existing table in an Oracle 10gR2 that I added a XMLTYPE
I'm working with SSIS 2008 and am having a problem calling an Oracle stored
I'm currently working on a project that needs to have a process that assigns
I have the following bit of code that reads data from the an Oracle
I am trying to fetch the different table names used in a SQL query
I am starting to work with Nhibernate and Oracle for a project. The database
We are currently working on an MVC proof of concept and are struggling with
I have 11g installed locally on my machine (Windows 7 64bit). When I have

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.