Advertisement

08.12.2008 at 03:23PM PDT, ID: 23642994
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.8

rollup returns too many rows

Asked by ewang1205 in Oracle Database

Tags:

The select returns rows with LEVEL4 ='None' or LEVEL5 ='None' or LEVEL6 ='None' .  I just need the rows with LEVEL4 , level5, level6 is blank like the following results.  How to modify the query?  Thanks.

GROUPING_ID(B.LEVEL3,B.LEVEL2,B.LEVEL1,B.LEVEL4,B.LEVEL5,B.LEVEL6)      SUM(SALARY)      LEVEL1      LEVEL2      LEVEL3      LEVEL4      LEVEL5      LEVEL6

7      300      DALLAS      TEXAS      USA                  
7      150      HOUSTON      TEXAS      USA                  
15      450            TEXAS      USA                  
7      400      CHICAGO      ILLINOIS      USA                  
15      400            ILLINOIS      USA                  
31      850                  USA                  
63      850                                    
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
select GROUPING_ID (b.level3, b.level2, b.level1 , b.level4,  b.level5, b.level6), 
sum(salary), b.level1, b.level2, b.level3 , b.level4,  b.level5, b.level6
from emp a, location b
where a.city = b.level1
group by rollup(b.level3, b.level2, b.level1, b.level4,  b.level5, b.level6);
 
 
drop table emp;
create table emp (emp_no number, salary number, city varchar2(20));
insert into emp values (1, 100, 'DALLAS');
insert into emp values (2, 200, 'DALLAS');
insert into emp values (3, 300, 'NEW YORK');
insert into emp values (4, 400, 'CHICAGO');
insert into emp values (5, 150, 'HOUSTON');
commit;
 
drop table LOCATION;
CREATE TABLE  LOCATION
(
  LEVEL1     VARCHAR2(20 BYTE),
  LEVEL2     VARCHAR2(20 BYTE),
  LEVEL3     VARCHAR2(20 BYTE),
  LEVEL4     VARCHAR2(10 BYTE),
  LEVEL5     VARCHAR2(10 BYTE),
 LEVEL6     VARCHAR2(10 BYTE),
  NODE_NAME  VARCHAR2(10 BYTE)
);
 
 
 
SET DEFINE OFF;
 
Insert into LOCATION  Values  ('CHICAGO', 'ILLINOIS', 'USA',  'None', 'None','None', 'CITY3'  );
 
Insert into LOCATION  Values  ('HOUSTON', 'TEXAS', 'USA',  'None', 'None', 'None','CITY1'  );
 
Insert into LOCATION  Values  ('DALLAS', 'TEXAS', 'USA',  'None', 'None', 'None','CITY2'  );
COMMIT;
 
 
[+][-]08.12.2008 at 06:51PM PDT, ID: 22218531

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]08.12.2008 at 06:52PM PDT, ID: 22218536

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle Database
Tags: oracle
Sign Up Now!
Solution Provided By: sdstuber
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.13.2008 at 02:29AM PDT, ID: 22220203

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628