Pivot table result without aggregate function
Hi all
We have the following two tables:
SQL > select * from class;
CLASS_ID COURSES
---------- ----------
1 1
2 1
3 1
2 2
3 2
5 2
6 selected lines.
SQL > select * of course.
COURSE_ID
----------
1
2
The customer needs the output in the following format:
class class class class
1 1 2 3
2 2 3 5
I considered using the operator pivot tables however they require the use of an aggregate function, but there is no aggregation only required in the result here - we demand that the output as would a PivotTable?
Try this.
WITH class(CLASS_ID,COURSE) AS)
1.1 DOUBLE UNION ALL SELECT
SELECT 2.1 DUAL UNION ALL
SELECT 3.1 FROM DUAL UNION ALL
SELECT 2.2 DUAL UNION ALL
3.2 DUAL UNION ALL SELECT
SELECT DOUBLE 5.2)
SELECT * FROM)
SELECT THE COURSE
CLASS_ID,
ROW_NUMBER () OVER(PARTITION BY COURSE ORDER BY COURSE) RN
CLASS)
PIVOT (MAX (CLASS_ID) for (RN) IN (1 as CLASS1, 2 AS CLASS2, CLASS3 AS 3));
OUTPUT:
CLASS CLASS1 CLASS2 CLASS3
-------- ---------- ---------- ----------
1 1 2 3
2 2 3 5
Tags: Database
Similar Questions
-
Joining tables with the aggregate function
I have 4 tables and I joined and I got my output variables. Joiner_1
I have another table and I used joiner_1 fields to match this table and had joiner_2. Then, I used aggregator on joiner_2 to get the sum and max values.
I traced all my outputs of the target of joiner_1 table. and 2 fields I got in Joiner_2 I have them at home to the target table, but it gives me error saying:
API8003: The attributes of the connection target group is already connected to a source of incompatible data. Use Carpenter or fixed operator to join the data upstream first before plugging it in this operator.
How to do this.
Basically, what I'm trying to do is.
example my target table has 10 fields
I get 8 fields by adhering to a set of tables, 2 other fields I need to get another table by matching the two my first join of output fields.
If my first join returns 8 rows for each row, it returns I could have several lines in the table of another that I need to get the money and put it in my table of objectives for the other 2 fields. My target table should be 8 rows after this is all done.
If I join my table another one at my first joints I get more lines.
Thanks in advance.Hello
Try this,
After the 4th Carpenter, I assume you have all three fields in there.
Add to your aggregator it and use a fith Carpenter and join the 4th and fifth Carpenter
you would have all three fields and the field of the aggregator
Then try to complete the objective.
If this does not work please let me know.
Published by: Dinesh.Sharma on June 8, 2009 09:31
Published by: Dinesh.Sharma on June 8, 2009 09:32
-
Query type pivot without aggregation function. Transposition of the
Hi experts,
Oracle 11g.
I have a table (see the sample code to reproduce), which has a date, a group and this group (determined in another query) County. I need a query of type pivot, but without aggregate functions. It's just for a view reports. I can't understand it. Thanks for your help.
Using SQL but I must return the following:CREATE TABLE temp_task AS SELECT TO_DATE ('15-NOV-2012') validation_date, 'GROUP 1' AS group_number, 42 AS monthly_count FROM DUAL UNION ALL SELECT TO_DATE ('14-DEC-2012') validation_date, 'GROUP 1' AS group_number, 33 AS monthly_count FROM DUAL UNION ALL SELECT TO_DATE ('15-NOV-2012') validation_date, 'GROUP 2' AS group_number, 10 AS monthly_count FROM DUAL UNION ALL SELECT TO_DATE ('14-DEC-2012') validation_date, 'GROUP 2' AS group_number, 32 AS monthly_count FROM DUAL UNION ALL SELECT TO_DATE ('15-NOV-2012') validation_date, 'GROUP 3' AS group_number, 7 AS monthly_count FROM DUAL UNION ALL SELECT TO_DATE ('14-DEC-2012') validation_date, 'GROUP 3' AS group_number, 9 AS monthly_count FROM DUAL;
VALIDATION_DATE | GROUP 1 | GROUP 2 | GROUP 3
15/11/2012. 42. 10. 7
14/12/2012 | 33. 32. 9Hello
You should always use an aggregate function while rotating.
Even if you have really no aggregation, in other words, when what you see in the table, it's what you will get in the result set, you will have to use an aggregate function. Is there is only a value contrinuting for each cell, then you can use the MIN or MAX. It will not matter which; Since there is only 1 value, this value will be the greater of 1, and it will be also the lowest. For NUMBER of columns, you can also use SUM or AVG.SELECT * FROM temp_task PIVOT ( MIN (monthly_count) FOR group_number IN ( 'GROUP 1' , 'GROUP 2' , 'GROUP 3' ) ) ORDER BY validation_date ;
Output:
VALIDATION_ 'GROUP 1' 'GROUP 2' 'GROUP 3' ----------- ---------- ---------- ---------- 15-Nov-2012 42 10 7 14-Dec-2012 33 32 9
Looks like you're doing real aggregation somewhere, to get monthly_count. It would be perhaps easier and more efficient to do the swivel at this time. What is the big picture here? Post some sample data, as it is before you calculate monthly_count and desired outcomes from these data (if it is different from what you have already posted), then we'll see if we can not aggregte it and pivot it at the same time.
-
analytical function and the aggregate function
What are the analytical function and the aggregate function. What is the difference between them?Hello
Analytic Functions : -.
Analytical functions calculate a value of aggregation based on a group of lines. They differ from aggregate functions because they return several rows for each group. The Group of rows is called a window and is defined by the analytic_clause. For each line, a sliding window of lines is defined. The window determines the range of lines used for the calculations for the current line. Window sizes can be based on a physical number of rows or a logic as the time interval.
Analytical functions are the last set of operations performed in a query with the exception of the last ORDER BY clause. Every joint and every WHERE, GROUP BY and HAVING clauses are met before the analytical functions are handled. As a result, analytic functions can only appear in the select list or the ORDER BY clause.
Analytical functions are commonly used to calculate cumulative aggregates, moving, centered and considered.Aggregate functions : -.
Aggregate functions return a line of single result based on the groups of lines, rather than on the unique lines. Aggregate functions can appear in selection lists, as well as in the HAVING and ORDER BY clauses. They are commonly used with the GROUP BY clause in a SELECT statement, where Oracle Database splits the rows in a table when asked or seen in groups. In a query that contains a GROUP BY clause, the select list items can be aggregation functions, GROUP BY constant expressions or expressions involving one of them. Oracle applies the functions of aggregation for each group of rows and returns a single result for each group line.
If you omit the GROUP BY clause, Oracle then applies any aggregate functions in the select list for all rows in the table queried or the view. You use aggregate functions in the HAVING clause to eliminate groups of the output based on the results of aggregate functions, rather than the values of the individual lines of the queried table or view.Let me know if you feel any problem understanding.
Thank you.Published by: varun4dba on January 27, 2011 15:32
-
Why don't PIVOT clause works with aggregate TRIP of 11g function?
Hi all!
I'm really confused as to what is considered an aggregate function in the context of the PIVOT clause in 11 g.
I've been playing with a lot of things related to collections lately and it took birth in an aside:
At this point, I'm sure we can all agree that the applicationCREATE TABLE TEST_COLL ( NODE_ID VARCHAR2(15 CHAR) NOT NULL, NODE_VALUE VARCHAR2(45 CHAR) NOT NULL, NODE_LEVEL NUMBER(1) NOT NULL ); CREATE OR REPLACE TYPE TREE_NODE AS OBJECT ( NODE_KEY VARCHAR2( 15 CHAR), NODE_NAME VARCHAR2(127 CHAR) ); CREATE OR REPLACE TYPE TREE_NODES AS TABLE OF TREE_NODE NOT NULL;
perfectly valid is that the function of COLLECTION is an aggregation function according to the [Official Documentation | http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions031.htm#i1271564]SELECT NODE_LEVEL, CAST(COLLECT(TREE_NODE(NODE_ID, NODE_VALUE)) AS TREE_NODES) AS NODES FROM TEST_COLL GROUP BY NODE_LEVEL;
But then, one of the two following queries should work
Yet, these two withSELECT CAST(REGION_NODES AS TREE_NODES) AS REGIONS, CAST(DEPARTMENT_NODES AS TREE_NODES) AS DEPARTMENTS, CAST(AREA_NODES AS TREE_NODES) AS AREAS, CAST(CENTRE_NODES AS TREE_NODES) AS CENTRES FROM (SELECT NODE_LEVEL, TREE_NODE(NODE_ID, NODE_VALUE) AS NODE FROM TREE_COLL ) PIVOT (COLLECT(NODE) FOR NODE_LEVEL IN (1 AS REGION_NODES, 2 AS DEPARTMENT_NODES, 3 AS AREA_NODES, 4 AS CENTRE_NODES ) ); or (better) SELECT REGION_NODES AS REGIONS, DEPARTMENT_NODES AS DEPARTMENTS, AREA_NODES AS AREAS, CENTRE_NODES AS CENTRES FROM (SELECT NODE_LEVEL, TREE_NODE(NODE_ID, NODE_VALUE) AS NODE FROM TREE_COLL ) PIVOT (CAST(COLLECT(NODE) AS TREE_NODES) FOR NODE_LEVEL IN (1 AS REGION_NODES, 2 AS DEPARTMENT_NODES, 3 AS AREA_NODES, 4 AS CENTRE_NODES ) );
Study further, I found the same behavior when you use the aggregate function in the PIVOT XMLAGG clause.ORA-56902: expect aggregate function inside pivot operation
Is this normal? And if this is the case, is there another way to get the result that I expected?
My version is
Thanks in advanceSQL> SELECT BANNER FROM V$VERSION; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for 64-bit Windows: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
Best regards
PhilippeMost likely a bug. But you can work around it by using any other aggregate for this group is composed of a single line and apply collect a rotated value. Yes, the cost is double aggregation. And also there is another cost - you must create the service card member other aggreations such as MAX/MIN, etc. will not work:
CREATE OR REPLACE TYPE TREE_NODE AS OBJECT ( NODE_KEY VARCHAR2( 15 CHAR), NODE_NAME VARCHAR2(127 CHAR), map member function f return varchar2 ) / Type created. CREATE OR REPLACE TYPE BODY TREE_NODE AS map member function f return varchar2 is begin return NODE_NAME; end f; end; / Type body created. CREATE OR REPLACE TYPE TREE_NODES AS TABLE OF TREE_NODE NOT NULL / Type created. SQL> select * 2 from test_coll 3 / NODE_ID NODE_VALUE NODE_LEVEL ------- ---------- ---------- 1 A 1 2 B 2 3 C 3 4 D 4 5 E 1 6 F 2 7 G 3 8 H 4 8 rows selected. SQL>
Now:
SELECT CAST(COLLECT(REGION_NODES) AS TREE_NODES) AS REGIONS, CAST(COLLECT(DEPARTMENT_NODES) AS TREE_NODES) AS DEPARTMENTS, CAST(COLLECT(AREA_NODES) AS TREE_NODES) AS AREAS, CAST(COLLECT(CENTRE_NODES) AS TREE_NODES) AS CENTRES FROM ( SELECT ROWID RID, NODE_LEVEL, TREE_NODE(NODE_ID, NODE_VALUE) AS NODE FROM TEST_COLL ) PIVOT (MAX(NODE) FOR NODE_LEVEL IN ( 1 AS REGION_NODES, 2 AS DEPARTMENT_NODES, 3 AS AREA_NODES, 4 AS CENTRE_NODES ) ) / REGIONS(NODE_KEY, NODE_NAME) DEPARTMENTS(NODE_KEY, NODE_NAME) AREAS(NODE_KEY, NODE_NAME) CENTRES(NODE_KEY, NODE_NAME) ---------------------------------------------------- ---------------------------------------------------- ---------------------------------------------------- ---------------------------------------------------- TREE_NODES(TREE_NODE('1', 'A'), TREE_NODE('5', 'E')) TREE_NODES(TREE_NODE('6', 'F'), TREE_NODE('2', 'B')) TREE_NODES(TREE_NODE('7', 'G'), TREE_NODE('3', 'C')) TREE_NODES(TREE_NODE('8', 'H'), TREE_NODE('4', 'D')) SQL>
SY.
-
SQL statement by using the min aggregate function result extract a line - how?
Need help, try to do something seemingly simple. I'll give a simple example to illustrate the problem.
I'll use a simple table of addresses with 4 fields.
Create the table:
complete with 6 rowsCREATE TABLE "ADDRESSES" ( "OWNER_NAME" VARCHAR2(20 BYTE), "STREET_NAME" VARCHAR2(20 BYTE), "STREET_NUMBER" NUMBER ) ;
We now have this:Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('FRED','MAIN',1); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JOAN','MAIN',2); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JEAN','MAIN',3); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JACK','ELM',1); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JANE','ELM',2); Insert into ADDRESSES (OWNER_NAME,STREET_NAME,STREET_NUMBER) values ('JEFF','ELM',3);
Select * from addresses
Now, I want to group by street name and obtain a number of houses. At the same time, I would like to know the number of the first and the last HouseOWNER_NAME STREET_NAME STREET_NUMBER -------------------- -------------------- ---------------------- FRED MAIN 1 JOAN MAIN 2 JEAN MAIN 3 JACK ELM 1 JANE ELM 2 JEFF ELM 3 6 rows selected
Excellent. Now for the problem. I would also like to list on each line, the owner who lives at number House first and/or the last. It should be noted, assume that the name of the street and the number is uniqueselect street_name, count(*) "NBR HOUSES", min(street_number) "First Number", max(street_number) "Last Number" from addresses group by street_name produces STREET_NAME NBR HOUSES First Number Last Number -------------------- ---------------------- ---------------------- ---------------------- ELM 3 1 3 MAIN 3 1 3 2 rows selected
It seems I have everything that I need. Don't know how to get home.
I tried:
But getting a syntax error sql group function unauthorized when I add the subselect statement.select street_name, count(*) "NBR HOUSES", min(street_number) "First Number", max(street_number) "Last Number", (Select b.owner_name from addresses b where b.street_number = min(street_number) and b.owner_name = owner_name) "First Owner" from addresses group by street_name
any ideas?
Thanks for any help.
Published by: user6876601 on November 19, 2009 19:08
Published by: user6876601 on November 19, 2009 19:30Hello
Welcome to the forum!
Get the minimum and maximum number for each street is a pretty simple concept; simpler to describe and simple to code.
Now you want to the owner_name associate the maximum and minimum, which is a concept more complex; a little more difficult to describe and, unfortunately, much less simple to code and much, much more difficult to explain:select street_name, count (*) "NBR HOUSES", min (street_number) "First Number", min (owner_name) KEEP (DENSE_RANK FIRST ORDER BY street_number) "First Owner", max (street_number) "Last Number", min (owner_name) KEEP (DENSE_RANK LAST ORDER BY street_number) "Last Owner" from addresses group by street_name ;
You will notice that I used min for "Original owner" and "last owner". Why is this?
The key word in these functions is the FIRST or the LAST word that comes after DENSE_RANK and before ORDER BY. The function at the beginning is simply a break.In other words, MIN in this context refers only to what needs to happen when there is a link to the first or last in the group. Even if such a thing is impossibe in your data, generic functions must have a mechanism to return a single owner_name when two or more rows have an equal right to having the highest street_number. For example, if we change the address of Joan in 1 hand, then MIN (street_number) is always 1, of course, but who is the person associated with the minimum street_number: Fred or Joan? Both have an equal claim that he owns with the smallest address on Main Street, but aggregate functions must return a single value, so we must have a mechanism to indicate to the system, whether to return 'JOAN' or 'FRED '. In this example, I arbitrarily in the network said een of tie, the lowest name, in alphabetical order, must be returned. In this case, 'FRED' would return, "FRED" prior to "JOAN".
Thank you for including CREATE TABLE and INSERT!
-
Performance of the aggregate function.
Hello
Version 11.2.0 Oracle
I'm not a PL/SQL Developer, however, I decided to write this aggregate out function. Oracle has it but I tried TimesTen database in memory that does not yet function stddev.
The code is as follows:
Now, it works very well and returns the results OK.CREATE OR REPLACE TYPE MyStddevImpl AS OBJECT ( v_power NUMBER, -- sum(power^2) of the column v_sum NUMBER, -- average value v_iteration NUMBER, -- count(1) STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT MyStddevImpl) RETURN number, MEMBER FUNCTION ODCIAggregateIterate(self IN OUT MyStddevImpl, value IN number) RETURN number, MEMBER FUNCTION ODCIAggregateTerminate(self IN MyStddevImpl, returnValue OUT number, flags IN number) RETURN number, MEMBER FUNCTION ODCIAggregateMerge(self IN OUT MyStddevImpl, ctx2 IN MyStddevImpl) RETURN number ); / show error CREATE OR REPLACE TYPE BODY MyStddevImpl AS STATIC FUNCTION ODCIAggregateInitialize(sctx IN OUT MyStddevImpl) RETURN number AS BEGIN sctx := MyStddevImpl(0,0,0); RETURN ODCIConst.Success; END; MEMBER FUNCTION ODCIAggregateIterate(self IN OUT MyStddevImpl, value IN number) RETURN number AS BEGIN self.v_sum := self.v_sum + value; -- used to get averages self.v_power := self.v_power + power(value,2); self.v_iteration := self.v_iteration + 1; -- total number of rows return ODCIConst.Success; END; MEMBER FUNCTION ODCIAggregateTerminate(self IN MyStddevImpl, returnValue OUT number, flags IN number) RETURN number AS v_avg number; BEGIN v_avg := self.v_sum/self.v_iteration; -- this is the average value -- sqrt((sum(power(amount_sold,2))-(count(1)*power(avg(amount_sold),2)))/(count(1)-1)) returnValue := sqrt((self.v_power - (self.v_iteration * power(v_avg,2))) /(self.v_iteration-1)); RETURN ODCIConst.Success; EXCEPTION WHEN VALUE_ERROR THEN RETURN ODCIConst.error; END; MEMBER FUNCTION ODCIAggregateMerge(self IN OUT MyStddevImpl, ctx2 IN MyStddevImpl) RETURN number AS BEGIN RETURN ODCIConst.Success; END; END; / show error CREATE OR REPLACE FUNCTION MyStddev (input NUMBER) RETURN number AGGREGATE USING MyStddevImpl; / show error exit
The problem I have is that it takes 10.5 sec to runselect mystddev(amount_sold) AS "My standard deviation", stddev(amount_sold) from sales; My standard deviation STDDEV(AMOUNT_SOLD) --------------------- ------------------- 259.78049 259.78049
Is there any scope to improve this code. Specifically can I use avg function in the code instead of working on myself?select mystddev(amount_sold) from ssdtester.sales; MYSTDDEV(AMOUNT_SOLD) --------------------- 273.172955 Elapsed: 00:00:10.48 Execution Plan ---------------------------------------------------------- Plan hash value: 1047182207 ---------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 5 | 1324 (1)| 00:00:16 | | 1 | SORT AGGREGATE | | 1 | 5 | | | | 2 | TABLE ACCESS FULL| SALES | 1000K| 4882K| 1324 (1)| 00:00:16 | ---------------------------------------------------------------------------- Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 4965 consistent gets 0 physical reads 0 redo size 558 bytes sent via SQL*Net to client 524 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
Thank you
Mich
Published by: Mich Talebzadeh on February 13, 2012 12:20>
May I ask what is the purpose of the model of aggregate by Oracle functions if it will be row-by-row and he's not going to be effective.
>
Oracle online the way you did in your function.Your function, using the technology of data cartridges, will be called by Oracle for EACH LINE it reads each line corresponding to your query. This requires a change in context of SQL, PL/SQL, and then back to SQL. It is a very expensive operation in terms of time.
The Oracle SQL engine is not that way for aggregate functions it provides. The functionality of data cartridge is provided to allow developers to extend Oracle to provide features that Oracle is not provde all. Use of these functions of cartridge cases, you develop may not be 'slow' because there is no equivalent Oracle to compare to. You can use the features of your new cartridge or do you without; you have no other choice.
You should always use SQL from Oracle to do the job unless you are doing something that can be done in SQL. Then you should use of Oracle PL/SQL features (for example in BULK of treatment) to do the more complex things. Finally if you need to do something just that Oracle cannot do with out-of-the-box SQL or PL/SQL, then you turn cartridge data, custom Java or C code or other external solutions which you can interface to Oracle.
The order of the solutions, you should look at is:
1 SQL
2 PL/SQL
3 Java/C external
4 data cartridgeHe explains a little better? (and it is frankly win again in a minute or two!)
-
How to include an aggregate function in a function user_defined
I created the following function to validate the value of the commission of a table I created
create or replace function validate_comm (number v_comm)
return a Boolean value
is
VCOMM employeesCopy.commission_pct%type;
Start
Select max (commission_pct) in vcomm
of employeesCopy
where commission_pct = v_comm;
If v_comm < vcomm then
Returns true;
on the other
Returns false;
end if;
end;
the service was created successfully, but when I run it as follows:
Start
If validate_comm (0.0) then
dbms_output.put_line ('True');
on the other
dbms_output.put_line ('False');
end if;
end;
He always gives the wrong data, even if the maximum value of commission_pct in my table is 0.4 but I always wrong whenever I run the function. Why? and is it true to put the aggregate function in the select statement?Hello
If you don't want to UPDATE to each row of the table, and then add a WHERE clause to your UPDATE statement.
You can do what you want without procedures or user-defined functions:
update employeesCopy set commission_pct = v_comm; where commission_pct < ( SELECT MAX (commission_pct) FROM employeesCopy );
You didn't post a test version of your table, so I can't really test this.
There are good reasons to want to do this in PL/SQL. If you have one, you can write a procedure reset_comm that executes the UPDATE above statement.
If you want to make the statement to UPDATE a bit simpler by writing a function defined by the user (even if the net result is more coding and complexity more) so I think that a function takes no arguments and returning the MAX (commission_pct) would be more useful than something that had a fight and has returned a value depending on whether the qualified argument one line update , but if you don't want such a function, its arguments must be the values to take into account when it decides whether a line is updated. Should what value (s) on each line you consider in deciding if this line is up to date? If it's just commission_pct, then your procedure reset_comm might look like this:create or replace procedure reset_comm (v_comm number) is begin update employeesCopy set commission_pct = v_comm; where validate_comm (commission_pct) = 'OK'; end;
-
Bug with the aggregate function and no group
When I run the following query:
I get this result:with the_table as ( select 1 as id, 100 as cost from dual union all select 2 as id, 200 as cost from dual union all select 3 as id, 300 as cost from dual union all select 4 as id, 400 as cost from dual union all select 5 as id, 500 as cost from dual ) select id, cost from ( select id, cost from the_table -- union all -- select 0 as id, sum(cost) as cost from the_table where 0 = 1 -- group by 1 ) order by id;
However, when I "uncomment" the line "Group 1", the query works as expected (without the id = rank 0).ID COST -- ------ 0 <null> 1 100 2 200 3 300 4 400 5 500
This occurs even when "the_table" is an array.
Someone else comes through this (and if so, how long is a problem)?
The database is 11.2.0.2.0 64-bit.
EDIT: It also happens without a Union - the following returns a single line (with null 0 and cost of id) without the Group By and no line with her:
Edited by: Donbot February 15, 2012 10:29select id, cost from ( select 0 as id, sum(cost) as cost from ( select 1 as id, 100 as cost from dual union all select 2 as id, 200 as cost from dual union all select 3 as id, 300 as cost from dual union all select 4 as id, 400 as cost from dual union all select 5 as id, 500 as cost from dual ) where 0 = 1 -- group by 1 ) order by id
Donbot wrote:
Someone else comes through this (and if so, how long is a problem)?The database is 11.2.0.2.0 64-bit.
This is a documented behavior.
http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions003.htm#SQLRF20035
"
All except COUNT (*) GROUPING and GROUPING_ID aggregate functions ignore NULL values. You can use the NVL function in the argument of an aggregation function to substitute a value for a null value. COUNTY and REGR_COUNT never return null, but return a number or zero. For all remaining functions of aggregation, * if the DataSet contains no line, * or if it contains only the rows with NULL values as arguments to the aggregate function, * then the function returns null.*
" -
Convert pivot table to a table in the same answers BI report
Hello
I have a simple BI answers report. I used a PivotTable when in fact I have no aggregate
so it would be faster performance (I said) to use a table for the view, rather than on a pivot table view.
Is there a quick way to convert a pivot table view to a table view, without having to re - select
all the columns all over again?
Thanks a lot for all the replies.
-Greguser1636556 wrote:
Thanks for your reply. How exactly "choose you as ' a table view. At runtime, I get the view composed upwards.
Then change the drop-down menu that says "Compound Layout" and choose "Table" currently? I tried that and
the PivotTable returned at run time. Or do I do 'View Edition' on the existing PivotTable and change something that
for a Table view?Thanks for your help.
-Greg
Compound mode is the "view holds that all views." On the upper right side, you can click on the Red 'X' and remove the Pivot Table view. You can then "Add View", and select the Table view. Compound mode will be your title and Table.
So to answer your question, no, not "change the drop down menu that currently says"Compound Layout"and choose"Table"that takes you only to the view of the Table, because it does not affect the report itself. That's why at run time, you still get the Pivot Table View. Follow my instructions in the previous paragraph. Good luck!
Edited by: David_T December 9, 2011 10:25
-
Running sum and Pivot Table graphics
Hello Experts,
I've shown measures execution of amounts in pivot table problem is when I try to pivotted results graphic I get the original values and not the running sum values. Is there a way to get around this or another way to do?
Thank you
Published by: ZaidN on June 29, 2010 07:20Do the following things.
(1) to restart all services
(2) use the resume function it shows the cumulative graph also
(3) accumulation of usage view on measure it in pivot does ' t shows resume graphic because the sum of runnung dynamically apply in pivot table, but the table takes the column.
...................
Vincent V -
Get the same results without line of sight
Hi gurus,
My version of the database is 10.2.0.4.0.
I have a couple of tables as follows:
I would like to get a query to return for each group, the person with less person_number (if no one assigned to the group, then the query must return again with an empty person group). I know I can do this by using for example:CREATE TABLE xxgroups(group_number NUMBER, description VARCHAR2(30)); INSERT INTO xxgroups VALUES(1,'Group 1'); INSERT INTO xxgroups VALUES(2,'Group 2'); INSERT INTO xxgroups VALUES(3,'Group 3'); INSERT INTO xxgroups VALUES(4,'Group 4'); INSERT INTO xxgroups VALUES(5,'Group 5'); CREATE TABLE xxgroup_persons(group_number NUMBER, person_number NUMBER, first_name VARCHAR2(30), last_name VARCHAR2(30)); INSERT INTO xxgroup_persons VALUES(1, 1, 'John', 'Smith'); INSERT INTO xxgroup_persons VALUES(1, 2, 'James', 'Smith'); INSERT INTO xxgroup_persons VALUES(1, 3, 'Joe', 'William'); INSERT INTO xxgroup_persons VALUES(2, 4, 'Julien', 'Ford'); INSERT INTO xxgroup_persons VALUES(2, 5, 'James', 'Kelly'); INSERT INTO xxgroup_persons VALUES(3, 6, 'Francis', 'Smith'); INSERT INTO xxgroup_persons VALUES(5, 7, 'Jerry', 'Ford'); INSERT INTO xxgroup_persons VALUES(5, 8, 'Alfred', 'Willis'); INSERT INTO xxgroup_persons VALUES(5, 9, 'Jon', 'Preston'); COMMIT;
but it would be possible to achieve the same results without inline mode?SELECT group_number, person_number, first_name, last_name FROM (SELECT a.group_number, b.person_number, b.first_name, b.last_name , RANK() OVER (PARTITION BY a.group_number ORDER BY person_number) person_order FROM xxgroups a, xxgroup_persons b WHERE a.group_number = b.group_number (+) ) WHERE person_order = 1 ORDER BY group_number; GROUP_NUMBER PERSON_NUMBER FIRST_NAME LAST_NAME ------------ ------------- ------------------------------ ------------------------------ 1 1 John Smith 2 4 Julien Ford 3 6 Francis Smith 4 5 7 Jerry Ford
Thank you.You can try this function KEEP:
scott@orapdt> SELECT a.group_number, 2 min(b.person_number) as person_number, 3 min(b.first_name) keep (dense_rank first order by person_number) as first_name, 4 min(b.last_name) keep (dense_rank first order by person_number) as last_name 5 FROM xxgroups a, xxgroup_persons b 6 WHERE a.group_number = b.group_number (+) 7 group by a.group_number; GROUP_NUMBER PERSON_NUMBER FIRST_NAME LAST_NAME ------------ ------------- ------------------------------ ------------------------------ 1 1 John Smith 2 4 Julien Ford 3 6 Francis Smith 4 5 7 Jerry Ford 5 rows selected.
-
Satellite U920T - 10G - touch screen without any function
Hello together,
I have been using the nice nice feature now for a few weeks and start to have trouble with him.
I have the problem that randomly touch screen without any function, I can touch the screen
but I want to, but without any reaction.It starts just besides the requests or anything before, I just browsing in the web site and a second to another.
If I restart the PC, everything works normally again, I still using the drivers that have been pre-installed and have no changes for the drivers so far.
Any suggestions, what could cause this problem?
Kind regards
Hello
In my opinion, a process that controls the touch screen hangs or does not answer more and as a result, you can not touch works.
Recommend reinstalling the driver of Toshiba + Toshiba UE driver page system.
If this is not enough to try the system recovery and test the device with factory settings. -
Why aggregate (sum, min) function returns a line (with a null value) even though my there is no lines satisfying the where clause. Pls find the below example
Select 1 from scott.emp where deptno = 1,011 - no row returned
Select sum (sal) in the scott.emp where deptno = 1,011 - returns a row with null as a value. The thing is that if there are no rows in the emp table with a floating point number of employee. (Sum) should not have been called.
Here's how that works:
http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions003.htm
All functions except aggregation
COUNT
(*),GROUPING
, andGROUPING_ID
ignore NULL values. You can use theNVL
function in the argument of an aggregation function to substitute a value for a null valueCOUNT
andREGR_COUNT
never return null, but returns a number or zero. For all the remaining functions of aggregation, If the DataSet has no rows, or contains only rows with NULL values as arguments to the aggregate function, then the function returns the value null. -
Question of pivot Table...
Hi all
We use OBIEE11g.I columns like this
month Total_amount pending Prodct name amount (Factcolumn) (fact_column)
XYZ Jan 100 50
200 53 xyz Feb
now, I want to display like this
sale jan Feb
Total_amount 50 100
Amount pending 200 53
WHN I use the pivot column table is displayed columns only it does not display the lines.
Please let me know.
Thank you
SriFirst of all, you need not have a dimension attribute in the application if you want to filter on this topic, so I'll ignore the Product column.
To clarify, we have the following table results: -.
Measure 2 months 1-3
Jan 10 20 30
Feb 40 50 60
Mar 70 80 90You want that it appears as follows: -.
Month Jan Feb Mar
Measure 1 10 40 70
Measure 2 20 50 80
Measure 3 30 60 90In OBIEE 11 g it is obtained simply by dragging the box labels of measure section of columns to the lines of PivotTable section.
Please mark it as useful / replied:
Andy.
Maybe you are looking for
-
Satellite A300 - lack of sleep/hibernate with connected LAN cable
Hello I've owned a 1FZ A300 for a few weeks and unfortunately it did not go into sleep mode or hibernation while the ethernet cable from the router is plugged in, even with other programs stopped. (Previously, I used an other non-Toshiba notebook wit
-
How to delete empty pages in iBook author
I have a few large iBooks in iBook author. It is necessary to resort to certain paragraphs. By removing parts of a paragraph, there are empty pages and I have no idea how to do to remove them. It is very young, because of the suspension of the empty
-
Speed of data recovery of DIAdem data base using data Finder Toolkit in LabVIEW
I have developed a LabVIEW code using the toolkit OR database search to extract the data from the tiara. I formed queries for data extraction. But data recovery takes more time to retrieve the data. I have attached my image of LabVIEW code with this
-
HP D1660: Discontinued printers
I wanted to know if the Deskjet D1660 printer has been abandoned.
-
E4200 Base on a browser utility unavailable
I manually configured my E4200 (v1, material, v1.0.03 firmware) months ago and it worked perfectly. My wireless PC and connected to the Internet perfectly. I connected the utility based on a browser occasionally when I needed to upgrade the firmwar