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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:57:32+00:00 2026-05-26T06:57:32+00:00

I have an Oracle query, which has something to the effect of Having Count(field)

  • 0

I have an Oracle query, which has something to the effect of

Having Count(field) > (Long SQL statement that returns one row)
Both sides of the query work alone, but together I get a “not a group by” expression.

When replacing the long SQL statement with a number it works, but I assumed the two were equivalent if only one row is returned?

Edit
After doing some playing around I realized:
… Table T … Having Count(field) > (Long SQL statement with Table A Where A.field = T.field)
It works when I replace T.field with any of the specific options for T.field, but when I reference T.field specifically I get the same “not a group by expression”

  • 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-26T06:57:33+00:00Added an answer on May 26, 2026 at 6:57 am
    SELECT ... 
    FROM Table T ...
    GROUP BY T.afield
    HAVING Count(T.anotherfield) 
           > (Long SQL statement with Table A Where A.somefield = T.afield)
    

    should work ok.


    SELECT ... 
    FROM Table T ...
    GROUP BY T.anotherfield
    HAVING Count(T.anotherfield) 
           > (Long SQL statement with Table A WHERE A.somefield = T.afield)
    

    should not work. A field (like T.afield) that is not included in the GROUP BY list, cannot be referenced in SELECT, HAVING or ORDER BY clauses. Only aggregate functions of that field can be referenced – you could have WHERE A.somefield = MIN(T.afield) for example.

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

Sidebar

Related Questions

I have a java.sql.Clob object which I populate from an Oracle query and then
Have a need for a sql query which will do cloning of Oracle user.
I have a following oracle sql query in which START_DATE is a number column
I have an oracle table which has a column that stores XML in a
I have a query that has ... WHERE PRT_STATUS='ONT' ... The prt_status field is
I have a join in a oracle query which looks like: FROM eiv.table1 eiv.table2
I have a piece of my query in Oracle that generates discrete percentile: ...
I have the following query that runs in my Oracle database and I want
As I had written in title, I have SQL query, run on Oracle DB,
I'm writing some JDBC code which calls a Oracle 11g PL/SQL procdedure which has

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.