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

The Archive Base Latest Questions

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

I have a how do I do this in Oracle? select a.field1 || ‘_’

  • 0

I have a how do I do this in Oracle?

select a.field1 || '_' || 
       b.field2 || '_' || 
       sum(c.field3)
  from table1 a, 
       table2 b, 
       table3 c
 where a.field1 || '_' || 
       b.field2 || '_' || 
       sum(c.field3) not in (select d.field1 || '_' || 
                                    e.field2 || '_' || 
                                    sum(f.field3)  
                               from table4 d, 
                                    table5 e, 
                                    table6 f
                              where conditional_info_to_join_the_tables 
                              group by d.field1, e.field2)
   and conditional_info_to_join_the_tables  
 group by a.field1, b.field2

The error I get is I can’t use the sum in the where clause

i have tried using

select a.field1 || '_' || 
       b.field2 || '_' || 
       sum(c.field3), 
       sum(c.field2) foo
  from table1 a, 
       table2 b, 
       table3 c
 where a.field1 || '_' || 
       b.field2 || '_' || 
       foo not in (select d.field1 || '_' || 
                          e.field2 || '_' || 
                          sum(f.field3)  
                     from table4 d, 
                          table5 e, 
                          table6 f
                    where conditional_info_to_join_the_tables 
                    group by d.field1, e.field2)
   and conditional_info_to_join_the_tables 
 group by a.field1, b.field2

but that foo was not an identified variable.

  • 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-15T11:59:23+00:00Added an answer on June 15, 2026 at 11:59 am

    Merely giving the sum and alias (foo) does not help because the aggregate occurs after the filtering (the where clause.

    The having clause is like a filter that applies after the aggregation:

    select a.field1 || '_' || b.field2 || '_' || sum(c.field3)
    from table1 a, table2 b, table3 c
    where conditional_info_to_join_the_tables
    group by a.field1, b.field2
    having a.field1 || '_' || b.field2 || '_' || sum(c.field3)
               not in ( select d.field1 || '_' || e.field2 || '_' || sum(f.field3) 
                        from table4 d, table5 e, table6 f
                        where conditional_info_to_join_the_tables 
                        group by d.field1, e.field2 )
    

    You will still need to write out the aggregate in full rather than aliasing—the reason behind this is a bit less obvious and is discussed in this answer over on dba.se: https://dba.stackexchange.com/a/21982/1396.

    Of course you can achieve the same with a subquery:

    select foo
    from( select a.field1 || '_' || b.field2 || '_' || sum(c.field3) as foo
          from table1 a, table2 b, table3 c
          where conditional_info_to_join_the_tables
          group by a.field1, b.field2 )
    where foo not in ( select d.field1 || '_' || e.field2 || '_' || sum(f.field3) 
                       from table4 d, table5 e, table6 f
                       where conditional_info_to_join_the_tables 
                       group by d.field1, e.field2 )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query in Oracle 10g: DELETE FROM BMAN_TP1.CELLS_ITEM TABLE1 WHERE EXISTS (
I have an image byte[] , this byte[] is coming from LDAP [Oracle Open
I have an Oracle database where I'm trying to select a user field from
I have strange oracle optimizer behaviour: SELECT a.id, a.date_insert, a.message#cnt FROM T_MESSAGE_TRANSMIT A, T_LIST
I have this query: SELECT to_number(gr.code) group_index, gr.NAME group_name, f.*, gr.description gr_desc FROM obj$groups
I have this stored procedure for Oracle: create or replace procedure bns_saa_message_get() <--- PROBLEM
I have an Oracle account (schema) of a remote Oracle database. By using this
I have created a table on an Oracle 10g database with this structure :
I'm getting crazy with this problem: I have got some Oracle SQL-Reports to redesign
I have a working custom UserNamePasswordValidator that calls into my Oracle DB. This class

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.