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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:26:43+00:00 2026-06-10T02:26:43+00:00

I am facing a problem with GROUP BY clause, and the data is not

  • 0

I am facing a problem with GROUP BY clause, and the data is not showing up as I would like to have:

I have the data like this:

-------------------------------------------------------------------
| Company   | Division | Business Area | Unit   | Name Full  | ID |
-------------------------------------------------------------------
| Company 1 | Div 1    | Business 1    | Unit 1 | Customer 1 | 01 |
| Company 1 | Div 1    | Business 1    | Unit 1 | Customer 2 | 02 |
| Company 1 | Div 1    | Business 1    | Unit 2 | Customer 3 | 03 |
| Company 1 | Div 1    | Business 3    | Unit 3 | Customer 2 | 02 |
| Company 1 | Div 2    | Business 1    | Unit 1 | Customer 4 | 04 |
....
....

In UI, I would like to have it displayed like this:

Company 1, Div 1, Business 1, Unit 1
   -- Customer 1  01
   -- Customer 2  02
Company 1, Div 1, Business 1, Unit 2
   -- Customer 3 03
Company 1, Div 1, Business 3, Unit 3
   -- Customer 2 02
Company 1, Div 2, Business 1, Unit 1
   -- Customer 4 04

I tried the query, and if I try to group by only using company, div, business and unit then I get the error: 00979: not a group by expression as I am not using all columns as I used in SELECT, but then I don’t get my required result.

Any idea how may I proceed?

  • 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-10T02:26:44+00:00Added an answer on June 10, 2026 at 2:26 am

    Jaanna,

    Your example dataset has 5 rows and your expected output contains 9 rows. Those extra 4 rows are aggregations per (company,division,business_area,unit) where name_full and id are being rolled up.

    Your example data:

    SQL> create table mytable (company,division,business_area,unit,name_full,id)
      2  as
      3  select 'Company 1', 'Div 1', 'Business 1', 'Unit 1', 'Customer 1', '01' from dual union all
      4  select 'Company 1', 'Div 1', 'Business 1', 'Unit 1', 'Customer 2', '02' from dual union all
      5  select 'Company 1', 'Div 1', 'Business 1', 'Unit 2', 'Customer 3', '03' from dual union all
      6  select 'Company 1', 'Div 1', 'Business 3', 'Unit 3', 'Customer 2', '02' from dual union all
      7  select 'Company 1', 'Div 2', 'Business 1', 'Unit 1', 'Customer 4', '04' from dual
      8  /
    
    Table created.
    

    The query:

    SQL> select company
      2       , division
      3       , business_area
      4       , unit
      5       , name_full
      6       , id
      7    from mytable
      8   group by company
      9       , division
     10       , business_area
     11       , unit
     12       , rollup((name_full,id))
     13   order by company
     14       , division
     15       , business_area
     16       , unit
     17       , grouping(name_full) desc
     18       , name_full
     19  /
    
    COMPANY   DIVISION BUSINESS_AREA UNIT   NAME_FULL  ID
    --------- -------- ------------- ------ ---------- --
    Company 1 Div 1    Business 1    Unit 1
    Company 1 Div 1    Business 1    Unit 1 Customer 1 01
    Company 1 Div 1    Business 1    Unit 1 Customer 2 02
    Company 1 Div 1    Business 1    Unit 2
    Company 1 Div 1    Business 1    Unit 2 Customer 3 03
    Company 1 Div 1    Business 3    Unit 3
    Company 1 Div 1    Business 3    Unit 3 Customer 2 02
    Company 1 Div 2    Business 1    Unit 1
    Company 1 Div 2    Business 1    Unit 1 Customer 4 04
    
    9 rows selected.
    

    You might want to conditionally display some column values or not, but I leave that as an exercise to you.

    Regards,
    Rob.

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

Sidebar

Related Questions

I'm facing this problem and could not get through by any means. Here is
Has anyone got any tips for this problem i'm facing. Its not complex, but
iam facing problem in passing array to view. this is my controller code.. function
I am facing problem to get variable from query string. I have used htaccess
I am facing a problem with the group table view in editing mode... I
This is a homework problem and I'm facing some difficulties to understand it. The
I'm facing a problem here : I have two tables : A users table
This question deals with teamwork and emails. I'm facing the following scenario. I have
I am facing problem in receiving email. I have a registration form, when form
This question has been asked before but I am facing a slightly different problem.

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.