Cube , Rollup
Hi
what is the difference between Cube and Rollup
and what's the difference if I say for example :
Group by ( job_id, Division_id) or I say : Group by (Division_id, Job_id) ;
ML.
Hi,
Mr.lonely wrote:
hi,
I could do that my self ...Great! Then you don't have to go throught the trouble of posting a message on this forum. The documentation is more reliable, and more comprehensive, than the answers you get here. The manual can be faster, and it's never sarcastic.
This forum is a great place for posting questions when the documentation isn't clear, or seems to be contradictory. For example: "The SQL language 11.2 manual gives this example: ... When I tried ths ... I expected the output to be ... but instead I got ... Why? The manual even says ...".
This forum is also a good place to ask questions about how to use features. For example: "This query with GROUP BY ROLLUP ... seems to do the same thing as this one using GROUPING SETS .... Are there any situations in which these 2 queries would not produce the same results? Is one of them better that the other in this case? I tried to to the same thing using CUBE, like this ... but I ggot this error: .... Are there any guidlines for when ROLLUP is better than GROUPING SETS, and when GROUPING SETS is better than ROLLUP?
Similar Messages
-
Aggreate functions(cube,rollup)
Hi,
Is it possible to use aggrgate funtions (cube, rollup) with Oracle Express ?
Thanks
MarcoI don't find any documentation about aggregate functions like cube, rollup, grouping set in XE librairy. But it works !
select MANAGER_ID, DEPARTMENT_ID, count(EMPLOYEE_ID)
from HR.EMPLOYEES
group by rollup MANAGER_ID, DEPARTMENT_ID);
select MANAGER_ID, DEPARTMENT_ID, count(EMPLOYEE_ID)
from HR.EMPLOYEES
group by cube (MANAGER_ID, DEPARTMENT_ID);
select MANAGER_ID, DEPARTMENT_ID, count(EMPLOYEE_ID)
from HR.EMPLOYEES
group by
grouping sets (MANAGER_ID, DEPARTMENT_ID);
It's great ! -
ROLLUP AND CUBE OPERATORS IN ORACLE 8I
제품 : PL/SQL
작성날짜 : 2000-06-29
========================================
ROLLUP AND CUBE OPERATORS IN ORACLE 8I
========================================
PURPOSE
ROLLUP 과 CUBE Operator에 대해 설명하고자 한다.
Explanation
ROLLUP operator는 SELECT문의 GROUP BY절에 사용된다.
SELECT절에 ROLLUP 을 사용함으로써 'regular rows'(보통의 select된 data)와
'super-aggregate rows'(총계)을 구할 수 있다. 기존에는 select ... union select
를 이용해 구사해야 했었던 것이다. 'super-aggregate rows'는 'sub-total'
(중간 Total, 즉 소계)을 포함한다.
CUBE operator는 Cross-tab에 대한 Summary를 추출하는데 사용된다. 모든 가능한
dimension에 대한 total을 나타낸다. 즉 ROLLUP에 의해 나타내어지는 item total값과
column total값을 나타낸다.
NULL값은 모든 값에 대한 super-aggregate 을 나타낸다. GROUPING() function은
모든 값에 대한 set을 나타내는 null값과 column의 null값과 구별하는데 쓰여진다.
GROUPING() function은 GROUP BY절에서 반드시 표현되어야 한다. GROUPING()은 모든
값의 set을 표현합에 있어서 null이면 1을 아니면 0을 return한다.
ROLLUP과 CUBE는 CREATE MATERIALIZED VIEW에서 사용되어 질수 있다.
Example
아래와 같이 테스트에 쓰여질 table과 data을 만든다.
create table test_roll
(YEAR NUMBER(4),
REGION CHAR(7),
DEPT CHAR(2),
PROFIT NUMBER );
insert into test_roll values (1995 ,'West' , 'A1' , 100);
insert into test_roll values (1995 ,'West' , 'A2' , 100);
insert into test_roll values (1996 ,'West' , 'A1' , 100);
insert into test_roll values (1996 ,'West' , 'A2' , 100);
insert into test_roll values (1995 ,'Central' ,'A1' , 100);
insert into test_roll values (1995 ,'East' , 'A1' , 100);
insert into test_roll values (1995 ,'East' , 'A2' , 100);
SQL> select * from test_roll;
YEAR REGION DE PROFIT
1995 West A1 100
1995 West A2 100
1996 West A1 100
1996 West A2 100
1995 Central A1 100
1995 East A1 100
1995 East A2 100
7 rows selected.
예제 1: ROLLUP
SQL> select year, region, sum(profit), count(*)
from test_roll
group by rollup(year, region);
YEAR REGION SUM(PROFIT) COUNT(*)
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
700 7
7 rows selected.
위의 내용을 tabular로 나타내어 보면 쉽게 알 수 있다.
Year Central(A1+A2) East(A1+A2) West(A1+A2)
1995 (100+NULL) (100+100) (100+100) 500
1996 (NULL+NULL) (NULL+NULL) (100+100) 200
700
예제 2: ROLLUP and GROUPING()
SQL> select year, region, sum(profit),
grouping(year) "Y", grouping(region) "R"
from test_roll
group by rollup (year, region);
YEAR REGION SUM(PROFIT) Y R
1995 Central 100 0 0
1995 East 200 0 0
1995 West 200 0 0
1995 500 0 1
1996 West 200 0 0
1996 200 0 1
700 1 1
7 rows selected.
참고) null값이 모든 값의 set에 대한 표현으로 나타내어지면 GROUPING function은
super-aggregate row에 대해 1을 return한다.
예제 3: CUBE
SQL> select year, region, sum(profit), count(*)
from test_roll
group by cube(year, region);
YEAR REGION SUM(PROFIT) COUNT(*)
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
Central 100 1
East 200 2
West 400 4
700 7
위의 내용을 tabular로 나타내어 보면 쉽게 알 수 있다.
Year Central(A1+A2) East(A1+A2) West(A1+A2)
1995 (100+NULL) (100+100) (100+100) 500
1996 (NULL+NULL) (NULL+NULL) (100+100) 200
100 200 400 700
예제 4: CUBE and GROUPING()
SQL> select year, region, sum(profit),
grouping(year) "Y", grouping(region) "R"
from test_roll
group by cube (year, region);
YEAR REGION SUM(PROFIT) Y R
1995 Central 100 0 0
1995 East 200 0 0
1995 West 200 0 0
1995 500 0 1
1996 West 200 0 0
1996 200 0 1
Central 100 1 0
East 200 1 0
West 400 1 0
700 1 1
10 rows selected.
===============================================
HOW TO USE ROLLUP AND CUBE OPERATORS IN PL/SQL
===============================================
Release 8.1.5 PL/SQL에서는 CUBE, ROLLUP 이 지원되지 않는다. 8i에서는 DBMS_SQL
package을 이용하여 dynamic SQL로 구현하는 방법이 workaround로 제시된다.
Ordacle8i에서는 PL/SQL block에 SQL절을 직접적으로 위치시키는 Native Dynamic SQL
(참고 bul#11721)을 지원한다.
Native Dynamic SQL을 사용하기 위해서는 COMPATIBLE 이 8.1.0 또는 그 보다 높아야
한다.
SVRMGR> show parameter compatible
NAME TYPE VALUE
compatible string 8.1.0
예제 1-1: ROLLUP -> 위의 예제 1과 비교한다.
SQL> create or replace procedure test_rollup as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
select year, region, sum(profit), count(*)
into my_year, my_region, my_sum, my_count
from test_roll
group by rollup(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE TEST_ROLLUP:
LINE/COL ERROR
10/8 PL/SQL: SQL Statement ignored
13/18 PLS-00201: identifier 'ROLLUP' must be declared
SQL> create or replace procedure test_rollup as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
sql_stmt := 'select year, region, sum(profit), count(*) ' ||
'from test_roll ' ||
'group by rollup(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||
nvl(my_region,' ') ||
' ' || my_sum || ' ' || my_count);
end loop;
close tab_cv;
end;
SQL> set serveroutput on
SQL> exec test_rollup
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
700 7
PL/SQL procedure successfully completed.
예제 2-1: ROLLUP and GROUPING() -> 위의 예제 2와 비교한다.
SQL> create or replace procedure test_rollupg as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
select year, region, sum(profit),
grouping(year), grouping(region)
into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region
from test_roll
group by rollup(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_ROLLUPG:
LINE/COL ERROR
12/4 PL/SQL: SQL Statement ignored
17/13 PLS-00201: identifier 'ROLLUP' must be declared
SQL> create or replace procedure test_rollupg as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
sql_stmt := 'select year, region, sum(profit), count(*), ' ||
'grouping(year), grouping(region) ' ||
'from test_roll ' ||
'group by rollup(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||my_region ||
' ' || my_sum || ' ' || my_count ||
' ' || my_g_year || ' ' || my_g_region);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_rollupg
1995 Central 100 1 0 0
1995 East 200 2 0 0
1995 West 200 2 0 0
1995 500 5 0 1
1996 West 200 2 0 0
1996 200 2 0 1
700 7 1 1
PL/SQL procedure successfully completed.
예제 3-1: CUBE -> 위의 예제 3과 비교한다.
SQL> create or replace procedure test_cube as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
select year, region, sum(profit), count(*)
into my_year, my_region, my_sum, my_count
from test_roll
group by cube(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_CUBE:
LINE/COL ERROR
10/4 PL/SQL: SQL Statement ignored
13/13 PLS-00201: identifier 'CUBE' must be declared
SQL> create or replace procedure test_cube as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
begin
sql_stmt := 'select year, region, sum(profit), count(*) ' ||
'from test_roll ' ||
'group by cube(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||
nvl(my_region,' ') ||
' ' || my_sum || ' ' || my_count);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_cube
1995 Central 100 1
1995 East 200 2
1995 West 200 2
1995 500 5
1996 West 200 2
1996 200 2
Central 100 1
East 200 2
West 400 4
700 7
PL/SQL procedure successfully completed.
예제 4-1: CUBE and GROUPING() -> 위의 예제 4와 비교한다.
SQL> create or replace procedure test_cubeg as
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
select year, region, sum(profit),
grouping(year), grouping(region)
into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region
from test_roll
group by cube(year, region);
end;
Warning: Procedure created with compilation errors.
SQL> show error
Errors for PROCEDURE TEST_CUBEG:
LINE/COL ERROR
12/4 PL/SQL: SQL Statement ignored
17/13 PLS-00201: identifier 'CUBE' must be declared
SQL> create or replace procedure test_cubeg as
type curTyp is ref cursor;
sql_stmt varchar2(200);
tab_cv curTyp;
my_year test_roll.year%type;
my_region test_roll.region%type;
my_sum int;
my_count int;
my_g_region int;
my_g_year int;
begin
sql_stmt := 'select year, region, sum(profit), count(*), ' ||
'grouping(year), grouping(region) ' ||
'from test_roll ' ||
'group by cube(year, region)';
open tab_cv for sql_stmt;
loop
fetch tab_cv into my_year, my_region, my_sum, my_count,
my_g_year, my_g_region;
exit when tab_cv%NOTFOUND;
dbms_output.put_line (my_year || ' '||my_region ||
' ' || my_sum || ' ' || my_count ||
' ' || my_g_year || ' ' || my_g_region);
end loop;
close tab_cv;
end;
Procedure created.
SQL> set serveroutput on
SQL> exec test_cubeg
1995 Central 100 1 0 0
1995 East 200 2 0 0
1995 West 200 2 0 0
1995 500 5 0 1
1996 West 200 2 0 0
1996 200 2 0 1
Central 100 1 1 0
East 200 2 1 0
West 400 4 1 0
700 7 1 1
PL/SQL procedure successfully completed.
Reference Ducumment
Note:67988.1Hello,
As previously posted you should use export and import utilities.
To execute exp or imp statements you have just to open a command line interface, for instance,
a DOS box on Windows.
So you don't have to use SQL*Plus or TOAD.
About export/import you may care on the mode, to export a single or a list of Tables the Table mode
is enough.
Please, find here an example to begin:
http://wiki.oracle.com/page/Oracle+export+and+import+
Hope this help.
Best regards,
Jean-Valentin -
Why has CAST(FieldName to float) failed in view but not in SELECT?
I've just solved a problem but I'm still not sure what the problem is!
I have a data (staging) table with all values stored as text. The data is converted to the correct data-type and also aggregated somewhat in a view. A select statement with the conversion works. A select statement with the conversion and aggregation (GROUP
BY) works. Creating a view of the conversion and aggregation works. However, on selecting from the view (e.g. SELECT TOP 1000 * FROM ViewName) it fails saying it cannot convert from varchar to float. There are no visible characters in the field apart from
numbers between 0 and 9, a decimal point and sometimes a leading minus sign (-).
The fix? Cast to money and then cast to float.
The problem? I don't know! What was the problem? Some of the values had up to 10 decimal places. Was that a problem? Was it really an overflow error masquerading as conversion error? The longest strings present were:
-2.609763091
-0.082456066
-0.674010546
-2.563428427
-0.016109637
-0.313600766
-0.104452264
-0.853811384
-0.302529502
-0.000362354
-0.002961949
-0.319269185
-0.001970796
Would really like to know what caused this so I can spot it in future before it happens.
Cheers.
JCEHOne possibility is that the two execution plans are different. The logical order of the way SQL processes the clauses a SELECT query is FROM, ON, OUTER, WHERE, GROUP BY, CUBE | ROLLUP, HAVING, SELECT, DISTINCT, ORDER BY, TOP. (Actually that's
what I learned, now there are some additional things like APPLY, but for our purposes we can ignore them). The important thing to know is that that is the LOGICAL order, but SQL is allowed (and often does) go change that order to anything it wants as
long as it returns the correct result.
So, for example, if your FROM clause a number of rows and some of those rows contain data which would cause a CAST (or anything else) in the SELECT clause to fail, but those rows are eliminated by your WHERE clause. Then SQL could do
FROM, WHERE, SELECT and the query works, or
FROM, SELECT, WHERE and the query fails. And, in general, you cannot control which plan SQL will use.
So, for example, if you have a table named T with two integer columns I and J and some rows in the table have a value of 0 in the column J and you run
SELECT I/J FROM T WHERE J<>0
it might work and you might get a divide by zero error. So one safe way to handle this is to write your query as
SELECT I/(CASE WHEN J <> 0 THEN J ELSE NULL END) WHERE J<>0
Another way would be to create a temp table and write an insert statement that inserted into that temp table only the rows where J<>0 and then do the query from the temp table. Since that is two SQL commands, SQL is forced to do them in order,
it cannot combine them and reorder the processing, that would look like
Create Table #T(I int, J int);
Insert Table #T(I, J)
Select I, J FROM T WHERE J<>0;
Select I/J From #T;
Drop Table #T;
You could try doing the equivalent of one of those to your query and see if that makes the problem go away.
Now I know you are going to ask "Why did the view use to work and it doesn't anymore?" and "Why does using the view and the table return different results". My guess is that you are getting different plans for the view and the table,
why that is, I don't know, it is often difficult to answer that type of question. My best guess for why the view used to work, then you ALTERED it, and then changed it back to the original form and it fails even though it is exactly the same as the old
view that was working is, when you had the old view, then was a cached execution plan that was working. That execution plan might have been created a good while ago. When you ALTERED it, you, of course, got a new plan. Then when you ALTERED
it back to the original form, it no longer had the plan it had been using, so had to create a new one, and this new plan was different than the old one.
Finally, if this is the cause of your problem, then you are not guaranteed that the convert to money, then to float is a permanent fix. If you have column headers which cannot be converted to either money or float, then it could be the convert to money
then to float is enough to get SQL to do the WHERE first, then the SELECT. But there is no guarantee that will be true forever. Changes in your data distribution and release level of SQL might make that version do the select first and then the
where.
Tom -
Summing columns to give a grand total
Hi,
I'm sure this is simple using one of the GROUP BY extensions, but I'm having a particularly dumb day
I have the following SQL
SELECT EGROUP.EDESC,
SUM(DECODE(PERS.AGERANGE,'UNDER 16',1,0)) AS "UNDER 16",
SUM(DECODE(PERS.AGERANGE,'16 - 25',1,0)) AS "16 - 25",
SUM(DECODE(PERS.AGERANGE,'26 - 35',1,0)) AS "26 - 35",
SUM(DECODE(PERS.AGERANGE,'36 - 45',1,0)) AS "36 - 45",
SUM(DECODE(PERS.AGERANGE,'46 - 59',1,0)) AS "46 - 59",
SUM(DECODE(PERS.AGERANGE,'60 +',1,0)) AS "60 +",
SUM(DECODE(PERS.AGERANGE,'UNKNOWN',1,0)) AS "UNKNOWN",
COUNT(PERS.PIN) AS "Total"
FROM (SELECT 1 ORD, 'WBRI' ECODE, 'White British' EDESC FROM DUAL UNION ALL
SELECT 2, 'WENG', 'White English' FROM DUAL UNION ALL
SELECT 3, 'WSCO', 'White Scottish' FROM DUAL UNION ALL
SELECT 4, 'WWEL', 'White Welsh' FROM DUAL UNION ALL
SELECT 5, 'WIRI', 'White Irish' FROM DUAL UNION ALL
SELECT 6, 'WOTH', 'White Other' FROM DUAL
) EGROUP,
(SELECT 1234 PIN, 'WBRI' PCODE, 'UNDER 16' AGERANGE FROM DUAL UNION ALL
SELECT 1235, 'WENG', '16 - 25' FROM DUAL UNION ALL
SELECT 1236, 'WENG', '16 - 25' FROM DUAL
) PERS
WHERE EGROUP.ECODE = PERS.PCODE(+)
GROUP BY EGROUP.EDESC, EGROUP.ORD
ORDER BY EGROUP.ORD ASC which produces
White British 1 0 0 0 0 0 0 1
White English 0 2 0 0 0 0 0 2
White Scottish 0 0 0 0 0 0 0 0
White Welsh 0 0 0 0 0 0 0 0
White Irish 0 0 0 0 0 0 0 0
White Other 0 0 0 0 0 0 0 0what I'd like is for a 'totals row' to also be output
White British 1 0 0 0 0 0 0 1
White English 0 2 0 0 0 0 0 2
White Scottish 0 0 0 0 0 0 0 0
White Welsh 0 0 0 0 0 0 0 0
White Irish 0 0 0 0 0 0 0 0
White Other 0 0 0 0 0 0 0 0
Total 1 2 0 0 0 0 0 3I really need to read the Data Warehousing manual, to try and understand how CUBE, ROLLUP and grouping sets work.
Thanks
DaveSQL> SELECT nvl(EGROUP.EDESC,'Total'),
2 SUM(DECODE(PERS.AGERANGE,'UNDER 16',1,0)) AS "UNDER 16",
3 SUM(DECODE(PERS.AGERANGE,'16 - 25',1,0)) AS "16 - 25",
4 SUM(DECODE(PERS.AGERANGE,'26 - 35',1,0)) AS "26 - 35",
5 SUM(DECODE(PERS.AGERANGE,'36 - 45',1,0)) AS "36 - 45",
6 SUM(DECODE(PERS.AGERANGE,'46 - 59',1,0)) AS "46 - 59",
7 SUM(DECODE(PERS.AGERANGE,'60 +',1,0)) AS "60 +",
8 SUM(DECODE(PERS.AGERANGE,'UNKNOWN',1,0)) AS "UNKNOWN",
9 COUNT(PERS.PIN) AS "Total"
10 FROM (SELECT 1 ORD, 'WBRI' ECODE, 'White British' EDESC FROM DUAL UNION ALL
11 SELECT 2, 'WENG', 'White English' FROM DUAL UNION ALL
12 SELECT 3, 'WSCO', 'White Scottish' FROM DUAL UNION ALL
13 SELECT 4, 'WWEL', 'White Welsh' FROM DUAL UNION ALL
14 SELECT 5, 'WIRI', 'White Irish' FROM DUAL UNION ALL
15 SELECT 6, 'WOTH', 'White Other' FROM DUAL
16 ) EGROUP,
17 (SELECT 1234 PIN, 'WBRI' PCODE, 'UNDER 16' AGERANGE FROM DUAL UNION ALL
18 SELECT 1235, 'WENG', '16 - 25' FROM DUAL UNION ALL
19 SELECT 1236, 'WENG', '16 - 25' FROM DUAL
20 ) PERS
21 WHERE EGROUP.ECODE = PERS.PCODE(+)
22 GROUP BY grouping sets ((EGROUP.EDESC, EGROUP.ORD),())
23 ORDER BY EGROUP.ORD ASC
24 /
NVL(EGROUP.EDE UNDER 16 16 - 25 26 - 35 36 - 45 46 - 59 60 + UNKNOWN Total
White British 1 0 0 0 0 0 0 1
White English 0 2 0 0 0 0 0 2
White Scottish 0 0 0 0 0 0 0 0
White Welsh 0 0 0 0 0 0 0 0
White Irish 0 0 0 0 0 0 0 0
White Other 0 0 0 0 0 0 0 0
Total 1 2 0 0 0 0 0 3
7 rijen zijn geselecteerd.Regards,
Rob. -
Can't understand how this group by clause works
The Schema is as below: (http://www.psoug.org/reference/rollup.html)
CREATE TABLE grp_rep (
person_id NUMBER(3),
division VARCHAR2(3),
commission NUMBER(5));
INSERT INTO grp_rep VALUES (1,'SAM',1000);
INSERT INTO grp_rep VALUES (2,'EUR',1200);
INSERT INTO grp_rep VALUES (1,'EUR',1450);
INSERT INTO grp_rep VALUES (1,'EUR',700);
INSERT INTO grp_rep VALUES (2,'SEA',1000);
INSERT INTO grp_rep VALUES (2,'SEA',2000);
INSERT INTO grp_rep VALUES (1,'EUR',800);
COMMIT;
Query1:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY person_id, ROLLUP (person_id, division);
Query2:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY division, ROLLUP (person_id, division);
The results of query1 are okay. It has results from rollup and group by person_id.
But, in Query2 results of rollup are missing and results of group by division is there.
Anyone can explain how the group by clause works when there are multiple columns involving CUBE, ROLLUP and simple column names?
Regards.Thank you shoblock!
but, What i m really looking for is,
How group by clause works when i add regular column along with RollUp in group by clause?
I have understood simple group by clause like
...group by column1,column2,column3....
n I also know simple rollup clauses like
...group by rollup(column1,column2,column3,...)
But my Problem is how does this work:
...group by column2,rollup(column1,column2,...)
...group by column1,rollup(column1,column2,...)
See below Results:
Query1:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY person_id,ROLLUP ( person_id, division );
Result:
PERSON_ID DIVISION SUM(COMMISSION)
1 EUR 2950
1 SAM 1000
2 EUR 1200
2 SEA 3000
1 3950
2 4200
1 3950
2 4200
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY division,ROLLUP ( person_id, division );
Query2:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY division,ROLLUP ( person_id, division );
Result:
PERSON_ID DIVISION SUM(COMMISSION)
1 EUR 2950
2 EUR 1200
1 SAM 1000
2 SEA 3000
1 EUR 2950
2 EUR 1200
1 SAM 1000
2 SEA 3000
EUR 4150
SAM 1000
SEA 3000
guys, help me make understand above results!
Regards. -
BUSINESS INTELLIGENCE ENHANCEMENTS
제품 : SQL*PLUS
작성날짜 : 2004-05-17
==================================
BUSINESS INTELLIGENCE ENHANCEMENTS
==================================
PURPOSE
Oracle 9i에서 강화된 BUSINESS INTELLIGENCE 관련 내용을 요약해 본다.
Explanation
아래의 내용에 대해 설명될 것이다.
- enhanced된 Oracle9i analytical functions
- Use grouping sets
- Create SQL statements with the new WITH clause
Example
1. enhanced된 Oracle9i analytical functions
1) Inverse percentile functions (역백분위수 함수)
: 특정 percent에 해당하는 값을 찾는데 사용된다.
percentile_disc : 특정 백분위수에 가까운 값을 return하는 함수.
percentile_cont : linear interpolation을 사용하여 연속적인
백분위수를 계산하는 함수
ex) 1999년 11월달의 distribution channel당 판매량의 50%에 가까운
discrete value을 찾아라.
select c.channel_desc, avg(s.quantity_sold), percentile_disc(0.5)
within group
(order by s.quantity_sold desc) percentile_50
from sales s, channels c
where c.channel_id = s.channel_id
and time_id between '01-NOV-1999' and '30-NOV-1999'
group by c.channel_desc;
2) What-if rank and distribution functions
: 만약 어떤 data가 add된다면 이 data가 어느정도의 rank나 percenage에
속하는지를 찾는데 사용한다. what if analysis에 해당한다.
RANK : 그룹에서의 순위
DENSE_RANK : 중복값을 배제한 순위
PERCENT_RANK
CUME_DIST
ex) 새로운 사람이 고용되어 $10000 을 받는다면 부서당 salary을 비교할때
어느 정도 rank인가?
select department_id, round(avg(salary)) avg_salary,
rank(10000) within group (order by salary desc) rank,
dense_rank(10000) within group (order by salary desc) dense
from employees
group by department_id ;
3) FIRST/LAST aggregate functions
: 각 그룹의 첫번째나 마지막 값을 나타낼때 사용한다.
ex) manager당 commission을 가장 많이 받는 사람과 적게 받는 사람을 구하라.
select manager_id,
min(salary) keep (dense_rank first order by commission_pct)
as low_comm,
max(salary) keep (dense_rank last order by commission_pct)
as high_comm
from employees
where commission_pct is not null
group by manager_id;
4) WIDTH_BUCKET function
: with_bucket은 oracle 8i의 ntile과 비슷하다. 차이점은 ntile은 있는 모든
값을 그냥 정해진 bucket의 수로 나누는 것이고. with_bucket은 최소,최상
값을 정할 수 있다는 점이 다르다.
만약의 시험성적을 저장하고 있는 테이블이 있으면 각 점수별 분포를 확인
할때 사용할 수 있다.
With_bucket(expression, 0, 100,10)
그러면 10점 단위로 bucket이 생성되고 각 점수별 해당 bucket이 return된다.
ex) Low boundary value = 3000
High boundary value = 13000
Number of buckets = 5
select last_name, salary ,
width_bucket(salary,3000,13000,5) as sal_hist
from employees ;
5) Grouping sets
: group by절에 사용되며 소계나 특정 level의 소계등을 구할때 쓰인다.
2. Use grouping sets
1) 아래의 세개의 그룹에 대한, product가 10,20,45이고 1999년 11월의 1,2일에
해당하는 값을 구하라.
Time, Channel, Product
Time, Channel
Channel, Product
select time_id, channel_id, prod_id, round(sum(quantity_sold)) as cost
from sales
where (time_id = '01-DEC-1999' or time_id = '02-DEC-1999')
and prod_id in (10,20,30)
group by grouping sets
((time_id,channel_id,prod_id),(time_id,channel_id),(channel_id,prod_id)) ;
2) GROUPING SETS vs. CUBE and ROLLUP (참고 bul#11914)
CUBE나 ROLLUP은 필요한 group만 볼수 없지만 9i에서는 1)와 같이 원하는
group만을 볼수 있다.
select time_id, channel_id, prod_id,
round(sum(quantity_sold)) as quantity_sum
from sales
where (time_id = '01-DEC-1999' or time_id = '02-DEC-1999')
and prod_id in (10,20,45)
group by cube(time_id, channel_id, prod_id);
3) GROUPING SETS vs UNION ALL
Grouping sets절 대신에 union all을 사용하는 것은 table을 더 많이
scan하게 되고 문장을 구사하기가 비효율적이다.
아래의 두 문장은 같은 결과를 return한다.
select time_id, channel_id, prod_id,
round(sum(quantity_sold)) as quantity_sum
from sales
where (time_id = '01-DEC-1999' or time_id = '02-DEC-1999')
and prod_id in (10,20,45)
group by grouping sets (time_id, channel_id, prod_id);
select to_char(time_id,'DD-MON-YY'),
round(sum(quantity_sold)) as quantity_sum
from sales
where (time_id = '01-DEC-1999' or time_id = '02-DEC-1999')
and prod_id in (10,20,45)
group by time_id
union all
select channel_id ,
round(sum(quantity_sold)) as quantity_sum
from sales
where (time_id = '01-DEC-1999' or time_id = '02-DEC-1999')
and prod_id in (10,20,45)
group by channel_id
union all
select to_char(prod_id) ,
round(sum(quantity_sold)) as quantity_sum
from sales
where (time_id = '01-DEC-1999' or time_id = '02-DEC-1999')
and prod_id in (10,20,45)
group by prod_id;
4) Composite Columns
아래의 세개의 그룹에 대한 product가 10,20,45이고 1999년 11월의 1,2일에
해당하는 값을 구하라.
Product
Product, Channel,Time
Grand Total
select prod_id, channel_id, time_id
, round(sum(quantity_sold)) as sales
from sales
where (time_id='01-DEC-1999' or time_id='02-DEC-1999')
and prod_id in (10,20,45)
group by rollup(prod_id,(channel_id, time_id))
3. Create SQL statements with the new WITH clause
복잡한 query의 Select절에서 같은 block을 한번 이상 query를 할때 쓰인다.
Query block의 값은 user의 temporary tablespace에 저장한다.
Perfoemance의 향상을 기대할 수 있다.
1) 전체 회사의 총 salary의 1/8보다 많은 부서를 구하라.
with
summary as (
select department_name, sum(salary) as dept_total
from employees, departments
where employees.department_id = departments.department_id
group by department_name)
select department_name, dept_total
from summary
where dept_total > (select sum(dept_total) * 1/8 from summary)
order by dept_total desc ;
2) 1)을 예전 version에서는 아래와 같이 구현하였다.
select department_name, sum(salary) as dept_total
from employees,departments
where employees.department_id=departments.department_id
group by department_name
having sum(salary) > ( select sum(salary) * 1/8
from employees, departments
where
employees.department_id=departments.department_id)
order by sum(salary) desc;
4. Benefits
Improved query speed
Enhanced developer productivity
Minimized learning effort
Standardized syntax
Reference Ducumment
Oracle 9i New features for DeveloperHi Rajasheker,
Without knowing the exact scenario it is hard to give you an answer but I hope the following broad guidelines might help you.
1) There must be some thing in common or it may be a case of wrong architecture/missing buseness requirements. Identify the relationship between these two.
2) Or, do they have a 100% parallel relationship by design? In this casse you need to create a high level common object (dummy) to facilitate the consolidatation process (for example company code or worst scheario sys-id) and enhance both cube as well as ODS.
3) Or, if it is a complex situation: Introduce a new object which can build a bridge between these two. Ask the business about the rules.
If it doesn't help, pl give more details.
Bala -
Having Percentage on the Totals line instead of SUM
Hi,
I have a report with several number columns and several percentage columns. I need to show a totals line with grand totals for the number columns, and overall percentage for the percentage columns - how can I achieve this? I guess there is a more general question about showing any non-SUM summary function on the totals line, such as AVG, COUNT, MIN, MAX etc.
I could do it as a UNION I suppose but then I have the problem of formatting the totals line, and this wouldn't really work for break groups, only a grand total.
Any ideas?
SteveYou might want to look into the CUBE, ROLLUP and GROUPING SETS (OLAP) extensions to the GROUP BY clause in SQL. They generate intermediate subtotals, break totals, grand totals, etc using plain SQL.
Here is a quick example of what I mean
http://htmldb.oracle.com/pls/otn/f?p=24317:190
I have chosen to use SUM(SAL), AVG(COMM) and MAX(SAL) as the aggregates, you can modify this as per your requirements.
The query is
select
empno,ename,job,deptno,
sum(sal) sum_sal,
avg(comm) avg_comm,
max(sal) max_sal
from emp
group by rollup(empno,ename,job,deptno)
having grouping_id(empno,ename,job,deptno) in (0,15)The GROUPING_ID gives a binary "bitmap" of which columns are showing a detail row vs. a aggregate/super-aggregate row. In this case, we want to show the lowest level of detail (0) and the highest grand total (15=binary 1111 or all bits turned on)
Again, you can tweak this to show intermediate subtotals, just take out that HAVING clause to see what you get and modify as needed.
Hope this helps.
Message was edited by:
Vikas -
hi olap guys
i have a question
i am working on olap application on oracle9i R2 DW, i built the data warehouse and did ETL process now i am confused why i need to build my olap application to use olap api although i can do all queries
using sql (including cube,rollup,rank .... )statements using fact,dimensions tables incuding ( materialized views and dimensions objects for query rewriter) instead of olap api and olap metadata , what olap api can do for olap that i can't do it using oracle sql.
and what i should do to use forcasting,what-if analysis with my olap application.
thanksI bet you will get hundreds of replies on this topic. I will try to summarize in short as much as possible.
If I understand correctly, your question is why should I build Analytical Workspaces (Oracle OLAP objects), when I can get most of the results using SQL statements with MVs?
Theoretically, you can do most of these stuff in SQL and whether you should build OLAP objects or not depends on what kind of application you are planning to build.
For example, if your reports are straight forward and do not include higher level of analytic, such as forecasting, complex calculations, time series (lead, lag) and year to date calculations then you may be ok to use the star schema (snowflake will also be ok). Also, if your data is highly sparse (there are no fact data for most of the dimension value combinations) you may be better of in relational world.
Now consider this scenario, you want to run reports which tell what would be the forecasted profit based on the historical data, market conditions/seasonality and you want to know 'how was your sales in this year/qtr compare to past couple of years/qtrs, or if you want to know, which of the top 5 products that are purchased by top 10 customers in geography that has sales growth more then 20% annually?' You will need AWs to answer these questions.
The Materialized views can only give you the aggregation data in a relational format,where as the AWs can give the aggregation in multidimensional format and will also provide you all the inbuilt calculations that are useful for analytical reporting.
Now, if you have decided to go for AWs, we can see how to built forecasting application and what-if analysis. Let us know.
Thanks -
Hi guys
we got a process chain failed due to rollup process where 10 cubes are rolled up and out of 10 for all the 9 cubes rollup is done for 1 cube it says thee is no initail fill i have gone to that failed cube and did selected that and did activate and did inital fill but i got some pop ups and i pressd later its keeps on failin daily
can i deactivae it and then active and filll the aggregats does it work?
plz healp me
cheers
dpHi,
See if OSS note 536433 (Incorrect data in the aggregate (duplicate records) ) is relevant for you.
Also chk out this link .....
Roll up issue.
Hope u will find the solution to ur problem in these....
Happy Life,
Aravind
Message was edited by:
Aravindakshan M R -
[RESOLVED] Flag Lowest/Leaf Level in multi-dimensions
Sample Data: http://www.sendspace.com/file/uwjz9p
Hi,
I'm having issue by flagging lowest/leaf level for CUBE rollup purpose, due to there's no parent or child relationship parameter table, thus the is_leaf / connect by function cannot be use :(
However it is pretty obvious to be differentiate because the data is at follow:
1
1.2
1.2.1
1.2.2
1.3
But when mixed up two or more columns it is very hard to flag the lowest level flag.
LOWEST_FG COL_A COL_B COL_C
N - 1
N - 1.2
Y - 1.2.1 - 1.1
N - 1.2.1 - 1.2
Y - 1.2.1 - 1.2.1
Y - 1.2.1 - 1.2.2
N - 1.2.1 - 1.2.2 - 1
Y - 1.2.1 - 1.2.2 - 1.1
Y - 1.2.1 - 1.2.2 - 1.2
N - 1.2.1 - 1.2.3
Y - 1.2.1 - 1.2.3.1
Y - 1.2.2
Y - 1.3 - 1.1
Y - 1.3 - 1.2
Y - 1.3 - 1.3.1
Y - 1.3 - 1.3.2
Y - 1.3 - 1.3.3 - 1.1
Y - 1.3 - 1.3.3 - 1.2
Y - 1.3 - - 1.1
N - 1.3 - - 1.2
Y - 1.3 - - 1.2.1
Y - 1.3 - - 1.2.2
Y - 1.3 - - 1.3.2
Edited by: Sphenix on 14-Sep-2012 10:16
Edited by: Sphenix on 14-Sep-2012 10:21
SAMPLE DATA
-- DDL for Table SAMPLE_LOWEST_FG_02
CREATE TABLE "DBO"."SAMPLE_LOWEST_FG_02"
( "LVL_ID" VARCHAR2(20 BYTE),
"CUST_ID" VARCHAR2(10 BYTE),
"CORP_ID" VARCHAR2(10 BYTE),
"PURPOSE_ID" VARCHAR2(10 BYTE)
) SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "SYSTEM" ;
SAMPLE DATA
REM INSERTING into DBO.SAMPLE_LOWEST_FG_02
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,'9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2.1',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2.2',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.2.3',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,'9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,'9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,'9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.1',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,'9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.2',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,'9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.3.99',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.1.99',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2','9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2','2',null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'5.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'5.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'7');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'8');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,'9');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2',null,null);
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','1.1.3.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','1.1.3.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','1.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.1.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.1.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.1.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.1.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.1.1.5');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.1.1.6');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.2.1.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.2.1.4');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','3.2.1.99');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','4.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','4.2.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','4.2.1.1');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','4.2.1.2');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','4.3');
Insert into DBO.SAMPLE_LOWEST_FG_02 (LVL_ID,CUST_ID,CORP_ID,PURPOSE_ID) values ('1.1','1.3.2.2.1','2','5.2');
Edited by: SHi,
Sphenix wrote:
Sample Data: http://www.sendspace.com/file/uwjz9p
Post the sample data (CREATE TABLE and INSERT statements) and requirements right in your message. If that information is already availabel on some other web page or file, it should be easy for you to copy and paste it.
Hi,
I'm having issue by flagging lowest/leaf level for CUBE rollup purpose, due to there's no parent or child relationship parameter table, thus the is_leaf / connect by function cannot be use :(Acutally, the data you posted (if I interpret it correctly) does have a parent-child relationship: '1' is the parent of '1.x' , where x is any number. You could use CONNECT BY and CONNECT_BY_ISLEAF, but I think it will be more efficient to use a semi-join (as shown below) or an EXISTS sub-query.
However it is pretty obvious to be differentiate because the data is at follow:Different things are obvious to different people. Even if you and I agree that the results are obvious, we might disagree on what those results are. Say what you want.
I'm guessing you want something like this:
SELECT p.*
FROM table_x p
LEFT OUTER JOIN table_x c ON c.col_a LIKE p.col_a || '.%'
OR ( c.col_a = p.col_a
AND c.col_b LIKE p.col_b || .%'
OR ( c.col_a = p.col_a
AND c.col_b = p.col_b
AND c.col_c LIKE p.col_c || '.%'
WHERE c.col_a IS NULL
;This assumes that col_a can not be NULL.
If you'd post CREATE TABLE and INSERT statements for the sample data, then I could test this.
Edited by: Frank Kulash on Sep 14, 2012 5:37 PM -
Summarising without temporary tables
Can you please help me out with this question:
I have a table containing the following attributes and data:
EquipInfo(
EquipmentID Number,
AbnormalityID Number,
NumOfOccurances Number
I have the following data in the table:
EquipmentID AbnormalityID NumOfOccurances
1 1 7
1 8 3
1 9 2
2 4 8
3 2 4
3 4 1
Now I need a cursor that returns the following information:
EquipID TotalAbn Description
1 12 7 of type 1, 3 of type 2, 2 of type 9
2 8 8 of type 4
3 5 4 of type 2, 1 of type 4
The restriction imposed was not to use temporary tables because the client doesn't permit us to interfere with their temporary tablespaces.
I need some guidance to proceed on accomplishing this objective using stored procedures and looping constructs available.
Can this be achieved using subqueries, CUBE/ROLLUP operations?
Can you please help me out on this issue?The first two columns in your result set can be derived just using the SUM aggregrate function:
select equipmentid, sum(numofoccurances) totalabn
from equipinfo
group by equipmentid;For the third column (description), you will need to write a PL/SQL function that takes an equipmentid as a parameter, loops through the associated rows and builds a string. Something like:
create or replace function ab_function
(p_equipment_id in equipinfo.equipmentid%type)
return varchar2
is
v_result varchar2(4000);
begin
for r in (select numofoccurances, abnormalityid
from equipinfo
where equipmentid = p_equipmentid) loop
v_result := v_result || ', ' || r.numofoccurances || ' of type ' || r.abnormalityid;
end loop
return (ltrim(v_result, ', '));
end;
/And then refer to this function in your select:
select equipmentid, sum(numofoccurances) totalabn, ab_function(equipmentid) description
from equipinfo
group by equipmentid; -
can anyone xplain rollup and cube function in Groupby clause
Google "rollup and cube in oracle" or
http://www.psoug.org/reference/rollup.html
HTH
Girish Sharma -
Summary Report with cube and rollup
hi guys,
i m working a oracle 9i, i need a summary report after query execution. im using rollup and cube but it is giving me unwanted rows as well. for ex below
Select
IRH_REFNO,IRH_TDATE,IRH_BDAMT,IRH_RLOCN, IRH_ILOCN,IRH_EXPECTED_DATE,IRH_ADD_USERID ,
count(*),
sum(irh_bdamt)
from IRH
where IRH_INTYPE='R'
and IRH_RLOCN='EDP'
group by cube(IRH_REFNO,IRH_TDATE,IRH_BDAMT,IRH_RLOCN, IRH_ILOCN,IRH_EXPECTED_DATE,IRH_ADD_USERID )
Order by IRH_TDATE asc
i want only two columns to be computed at the end of query. i.e sum of BDAMT and count of rows. i dont want any groupings. any alternate for this.
thanks n regards
fkhanPlease post a create table statement, a few insert statements and the expected output, so we can help you.
Regards,
Rob. -
How to rollup cube data in Process chain?
I have loaded data into a cube, and when i look at the technical status it is green but there is nothing in the "request for reporting available"box. I went to Rollup Tab and manually execute the request. It worked.
But is there anyway that I can add a process type to do it automatically? I saw there are three process type related to Rollup, which one should I use?
1. Initial Fill of New Aggregates
2. Roll Up of Filled Aggregates/BIA Indexes (what does this mean?)
3. initial Activation and Filling of BIA Indexes
Thank you!Dear experts,
We have the following problem: for certain figures we have on ODS level 2 daily updates: one at night and one at noon. During the week at noon we only load from the ODS into the Cubes only that data that is entered the same day (selection on CPU-Date in the InfoPackage). After loading the data at night we load the data which was entered the previous day (selection on CPU-Date in the InfoPackage). In this process we have a step in the process chain that deletes in the overlapping request of the previous day (which was loaded at noon).
Our Process Chain for loading the data from ODS into the cubes looks as following:
Delete Indexes of the cubes -> Load data from ODS into Cubes -> Generate Cube Indexes -> Delete overlapping Requests in InfoCubes
After filling the BIA-Indexes on this cube, the process chain gives an error message at the stage where the overlapping request should be deleted. The error messages says:
Uncaught Exception: Keyfigure is of type Float.
To solve this error at the moment we manually delete the BIA Indexes, delete the overlapping requests and fill the BIA Indexes again. Since the functions 'delete BIA Index' and 'Fill BIA Index' is not available in RSPC we can not do this automatically in the process chain.
I also tried like above mentioned taking the step 'roll up filled BIA Indexes' into the process chain, but the check of the process chain creates a message stating that i cannot do this when in the same process chain the steps 'Delete Indexes of the Cube' and 'generate Indexes of the cubes' are included.
Does anybody know a solution how i can delete overlapping requests in a process chain with filled BIA Indexes.
Many thanks in advance for your kind reply.
Best regards,
Ilja Dekeyser
Maybe you are looking for
-
A lot of my saved passwords are for different pages on the company internal network. Since there is only one password for all these pages it would be easier if I could change all of them in one go when I change the password. I haven't seen any way to
-
To allocate to production order using template
hi everybody! I am having issue about allocating cost. In product costing, there is a cost, called Batch cost. That means all cost which is relevant a production batch is only allocated to production orders belong that batch. I am opposed to use Busi
-
Convert 360 degree photo to panoramio
I made some 360 degree photo's with my Sony Bloggie. I assumed that iPhoto (or iMove/Photoshop) could remap that picture to a rectangular panoramio photo, but until now I've been unsuccessful. Does somebody know if this is possible, and if not what t
-
How to get a movie from itunes to my ipod touch?
i recently downloaded a digital HD copy of Frozen. It made it into my itunes library but I can't get it to load on my ipod touch. I've tried transferring purchases and syncing to no avail.
-
Extend ISE Guest portal provisionig form
Hi, is it possibile to customize the Guest Portal by adding some fields in the registration form ? For example I need to add: input text field used to enter guest ID number dropdown menu containing a list of organizational unit prepopulated with an l