Alternative to Group by in oracle 9i
Dear All;
I currently have a query which is generating 10,000 rows but when I try applying a simple group by it affects the performance of the query. Hence, is there an alternative to using group by. Thank you.
but when I try applying a simple group by it affects the performance of the query.If you could show us the query + execution plan with and without the group by, we could have suggestions...
Adding a GROUP BY to a query that performs nicely, will of course add some additional required cpu processing, but shouldn't necessarily have to change the way the rows that need to be grouped are retrieved.
Similar Messages
-
Alternative Item group not appearing CS11
Hi all,
We have created BOM with all the substitution materials which can be used at the time of Production.
We have utilised the Alternative item group for this. When i look at BOM for a material say X using CS03 i can see the Alternative Item group. But when i explode the BOM using CS11 i cannot see the alternative item group in it.
The scenario in details is :
For the header material X i have X1,as component with different change numbers and unique validity dates and this component is seen in 3 lines in BOM with alternative item groups against it.
Now when i explode the BOM using CS11 i can see X1 component with alternative group for only 2 line items.
We are in ECC6.0 version, can i ask you whether there is any patch or oss note to be applied.I have tried searching OSS notes but couldnt find them
Please advice as this is of very high importance.
Thanking you
Regards
Raj KiranDear Raj,
What I wanted to confirm from you is ,after executing CS11--->
Changing Layout -
> Selecting Alternative Item group,
priority,Usage probablitity,the values are not shown in the field
properly though they are actually present in the BOM?
So enter the proper valid from dates in CS11(Select the date
on which the alternative item group is active) & also alternative
BOM number properly.
So go ahead as I suggested and even after entering the proper
valid from dates,Alt.BOM---changing layout ,if its not giving
proper results,then go for checking OSS notes.
This is with respect to ECC 6.0.
Check & revert back.
Regards
Mangal -
How to subscribe to a group space in Oracle Web Center application
Hi All,
I am a newbie to Oracle Web Center and playing in and around with the Oracle WebCenter Spaces..
At the time of creation of Group Space in Oracle WebCenter Application, there are two options :
1. Adding the members by the owner of the group space
2. Opening the open group space which allows others users can join by searching the specified GroupSpace and joining into that group space.
If i try to do like this, I was getting this error :
WCS#2010.07.21.15.05.39: Unable to send subscription notification to moderator(s). The reason is : Can not retrieve group space workflow configuration. Please contact administrator.
Can anyone please help me to solve this out..
Thanks in advance
Regards,
Sandeep
Edited by: user10681665 on 22-Jul-2010 02:13Sandeep,
To get this notifications to work, you need to setup BPEL and connect WebCenter to your BPEL server.
Regards,
Rob -
Hello Experts,
I have one issue in BOM alternative item group I have made the settings as below.
Material 1 AltItemGroup 01
Priority 1
Strategy 2 100% check
Usage prob. 100
Material 2 AltItemGroup 01
Priority 2
Strategy 2 100% check
Usage prob. 100
For Material 1 required bill of material quantity is 65 MT
For Material 2 required bill of material quantity is 65 MT
Now I am creating the process order for quantity 1000 MT. When the material availability check done it proposing as below in process order.
Material 1 = 65 MT (Available Stock 807.109 MT)
Material 2 = 0 MT (Available Stock 5.850 MT)
And again Material 2 = 32.5 MT
My question is as per above settings and stock situation of the material it should propose only Material 1 = 65 MT. But here system is also proposing Material 2 = 32.5 MT. Can any one tell what I am doing wrong?
Any settings are missing or what will be output for the above settings.
Please explain in detail.
Thanks in Advance
Regards,
GaneshHi Ganesh,
Pl. make the following settings:
Material 1 AltItemGroup 01
Priority 1
Strategy 2 100% check
Usage prob. 100
Material 2 AltItemGroup 01
Priority 2
Strategy 2 100% check
Usage prob. 0
The strategy 2 will automatically handle the situation when Material 1 is not available and 2 is available.
Pl. test & revert. It will work as per your requirements
Regards,
HKV... -
How to relink Oracle binaries to new OS group assinged to oracle account
Hello,
Can someone tell us the steps how to relink oracle binaries to new OS group assinged to oracle account.
Regards,
Nikhil Jainalways post your questions with oracle version and operating name and version.
refer the link:-
http://oracle.erkansaka.org/2008/04/how-to-change-oracle-dba-group-in-unix.html
http://dbaforums.org/oracle/index.php?showtopic=7279
Thread: "change the DBA group" in a windows environment
"change the DBA group" in a windows environment -
Alternative to Group By?
Hi
I have a query that has in its Select the Max function and of course a Group By. Whilst the query itself is returns the correct results, when running this through the correct cost analysis it is showing that the cost is very high. I have checked that it is this combination that is causing this and there are no joins. Therefore, is there alternative to using Group Bys, or is there away to make these kind of queries more efficient?
Can anyone advise me?user633278 wrote:
It is a general question rather than asking for actual help to an SQL query. My question is whether there is an alternative to GROUP BY and MAX when the cost is high?Sometimes you can quickly get a MAX value of a certain column by using an index.
For instance, suppose you'd want to get the max salary of all employees working in a certain departement.
And also suppose you have this index available to you:
create index emp01 on emp(deptno,sal);Instead of writing this query:
select max(sal) into pl_maxsal
from emp
where deptno = :b1;
...This query might perform an index range scan to retrieve all employees in that department and then perform a sort or hash group by to get the max salary.
You can also write it like this:
cursor c1(p_deptno number) is
select sal from emp where deptno = p_deptno order by sal desc;
open c1;
fetch c1 into pl_maxsal;
close c1;
..This query might do an index range scan descending, to just get the first row, which will have the max salary of that department.
Edited by: Toon Koppelaars on May 19, 2011 6:11 AM -
how to create an alternative iteam group for the bom .
what is the use of itHi
You can go through the following notes which is self explanatory.
Alternative item: group
Consolidation of alternative items within a BOM. Every material in the assembly can be included in the alternative item group.
Use
As soon as you enter an alternative item group, you see an additional dialog box with the following data: ranking order, strategy, usage probability.
You can maintain alternative items in the following situations:
Alternative positions with specific usage probability
These alternative items are incorporated with a specific usage probability. Enter the usage probability for each alternative item in the group, so that:
dependent requirements are determined in requirements planning
dependent requirements are changed to a reservation in the production order
Alternative positions as information
You can enter an alternative item for information purposes. This item would then, for example, only be taken into account in situations involving missing parts.
As there should be neither dependent requirements nor a reservation for this item, enter no usage probability.
Procedure
Enter the same character string to denote the alternative items of an alternative item group.
Enter the same strategy for all alternative items in the alternative item group.
Dependencies
Alternative items are valuated in the following way:
Dependent requirements determination
Requirements planning determines the dependent requirements according to the usage probabilities that have been entered.
If the usage probability is 0%, then no procurement is planned for the item. For information purposes, however, dependent requirements with 0 as quantity are created.
Withdrawal posting
You can control the withdrawal posting for the resevation in the production order in the following way:
Withdrawal according to usage probability (manual change is possible)
Withdrawal if there is 100% availability
Pl. try in these lines .
If you still have problem pl. get back.
Regards
YMREDDY -
Did anyone know why oracle 8i did not return the rows in order coloumns used in the group by condition ?
Eg.
select emp_name,count(*)
from employees
where department = '971'
group by emp_name
The above query returned the count in name order in 7.3 by not in oracle 8i
Any help.
Thanks
A KThe problem is we converted the application from developer 2000 to forms 6i. It worked fine in 7.3. We are not sure in how many places we used this group by.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>
Originally posted by harry dhillon:
Try using an 'order by ' clause if you want to have returned in a certain order.<HR></BLOCKQUOTE>
null -
How to display different text for labels in Group Above Report Oracle Repor
Hello,
Is there a way to change the text that is displayed in Labels in a Group Above Report? For example, I have a Group Above report with my columns of data and above the columns I have my column labels, but I would like to be able to display various text, i.e. different labels based on condition. In other words, Column1 label could say Column 1 or This is Column1, based on a condition. This is Oracle Report Builder 10.1.2.0.2.
Thank you.968277 wrote:
I'm thinking it is possible with a Format Trigger, but I've only ever returned (TRUE) or (FALSE). I am very new to Oracle Reports Builder. Thanks.Hi,
Yes it's possible. and your are in the right place. use this true and false. For example
/*true means display, false means don't display */
if your_criteria_or_condition is ok then
return (TRUE);
else
return (FALSE);
end if;create as many label as your need and control with the code..
Hope this works..
Hamid
Mark correct/helpful to help others to get right answer(s).* -
Not able to create a Volume Group in the oracle VM server installation
Hi,
I am installing Oracle VM server. In the installtion ( Partition time ), i click on create custom layout and i want to create a / partition as a logical volumn under volume group. But there is no option to create a Volume group actually. So can anybody help how to create a volume group actually and how to create a logical volume under volume group.user10274248 wrote:
So can anybody help how to create a volume group actually and how to create a logical volume under volume group.LVM is not recommended in Dom0, which is why support for LVM has been removed from the installer. LVM is not cluster aware and does not support write barriers, both of which are important for a filesystem that is used for storing file-backed disk images. -
Alternative for 'group by' needed
Remove group by and sum using Itab
Hello,
One report has a select clause which is retrieving SUM (field) AS field in the field list and USING group by 6-7 fields...
I want to remove this group by clause, take all records ( without sum ) into another internal table, sort it by these 6 fields ( will define them at the start of structure), loop through it and then use AT NEW for these 6 fields and use collect for summing the field.
Please give mee some hints or if there is any other alternative.?
Please advice.
Thanks,
Rupalee.HI,
You need to use the SORT and Internal Table Events ..
SORT ITAB BY FIELD1 FIELD2.
LOOP AT ITAB.
L_SUM = L_SUM + ITAB-FIELD3.
AT END OF FIELD2.
MOVE DATA TO ITAB2.
APPEND ITAB2.
ENDAT.
ENDLOOP. -
Not a GROUP BY expression - Oracle 10g bug?
Hi,
I am geting 00979. 00000 - "not a GROUP BY expression" error on Oracle 10g 10.2.0.4.0 - 64bit Production.
To illustrate my problem I created following example.
Let think I have some shop with clothes. Everytime I sell something, I store this information in the database - storing actual time, clothes type (trousers, socks, ...) and the size of the piece (M, L, XL, ...).
Now, system counts statistics every hour. So it goes thrue the table with sold pieces and counts the number of pieces per clothes type and per size from the beginning of the day. It is important to realize that it is from the beginning of the day. Because of that, the number of sold pieces in the statistical table grows every hour (or is at least on the same value as in previous hour).
Now, from this statistical table I need to make new statistic. I want a statistic how many pieces per size I sold every hour.
I created this query for that:
SELECT TIME, xSIZE, (SOLD - NVL((SELECT SUM(S1.SOLD)
FROM STATISTICS S1
WHERE S1.xSIZE = S.xSIZE
AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
AND TO_CHAR(S1.TIME, 'HH24') != '23'
AND S1.xSIZE IS NOT NULL
GROUP BY TRUNC(S1.TIME, 'HH24'), S1.xSIZE),0)) SOLD
FROM(
SELECT TRUNC(S.TIME, 'HH24') TIME, S.xSIZE, SUM(S.SOLD) SOLD
FROM STATISTICS S
WHERE S.xSIZE IS NOT NULL
GROUP BY TRUNC(S.TIME, 'HH24'), S.xSIZE
--ORDER BY 1 DESC
) S
ORDER BY TIME DESC, xSIZE ASCFirst I select number of sold pieces per hour per size. To get number of sold pieces for particular hour, I need to substract from this value number of sold pieces from previous hour. I decided to do this with parameter query...
Running the query like this I get "not a GROUP BY expression" error. However if I uncomment the "ORDER BY 1 DESC" statement, the query works. I am pretty sure it has to do something with this line:
AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
If you modify this query like this:
SELECT TIME, xSIZE, (SOLD - NVL((SELECT SUM(S1.SOLD)
FROM STATISTICS S1
WHERE S1.xSIZE = S.xSIZE
--AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
AND TO_CHAR(S1.TIME, 'HH24') != '23'
AND S1.xSIZE IS NOT NULL
GROUP BY S1.xSIZE),0)) SOLD
FROM(
SELECT TRUNC(S.TIME, 'HH24') TIME, S.xSIZE, SUM(S.SOLD) SOLD
FROM STATISTICS S
WHERE S.xSIZE IS NOT NULL
GROUP BY TRUNC(S.TIME, 'HH24'), S.xSIZE
--ORDER BY 1 DESC
) S
ORDER BY TIME DESC, xSIZE ASCRemoved joining the tables on truncated time and grouping by the truncated time -> The query does not fail...
And now the best...if you run the first query on Oracle 11g (Release 11.1.0.6.0 - 64bit Production), it works.
Does anybody know why is the first query not working on 10g? Is there some bug or limitation for this server version?
Please don't say me to rewrite the query in another way, I already did it, so it works on 10g as well. I am just curious why it doesn't work on 10g.
Finally here are some data for testing.
CREATE TABLE STATISTICS(
TIME DATE DEFAULT SYSDATE,
TYPE VARCHAR2(20),
xSIZE VARCHAR2(2),
SOLD NUMBER(5,0) DEFAULT 0
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'T-Shirt', 'M', 10);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'M', 3);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'T-Shirt', 'L', 1);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'L', 50);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Trousers', 'XL', 7);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 2/24, 'Socks', 'XL', 3);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'T-Shirt', 'M', 13);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Socks', 'L', 60);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Trousers', 'XL', 15);
INSERT INTO STATISTICS(TIME, TYPE, xSIZE, SOLD) VALUES(SYSDATE - 1/24, 'Socks', 'XL', 6);Edited by: user12047225 on 20.9.2011 23:12
Edited by: user12047225 on 20.9.2011 23:45It is a known issue when optimizer decides to expand in-line view. You can add something (besides ORDER BY you already used) to in-line view to prevent optimizer from expanding it. For example:
SQL> SELECT TIME,
2 xSIZE,
3 (SOLD - NVL(
4 (
5 SELECT SUM(S1.SOLD)
6 FROM STATISTICS S1
7 WHERE S1.xSIZE = S.xSIZE
8 AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
9 AND TO_CHAR(S1.TIME, 'HH24') != '23'
10 AND S1.xSIZE IS NOT NULL
11 GROUP BY TRUNC(S1.TIME, 'HH24'),
12 S1.xSIZE
13 ),
14 0
15 )
16 ) SOLD
17 FROM (
18 SELECT TRUNC(S.TIME, 'HH24') TIME,
19 S.xSIZE,
20 SUM(S.SOLD) SOLD
21 FROM STATISTICS S
22 WHERE S.xSIZE IS NOT NULL
23 GROUP BY TRUNC(S.TIME, 'HH24'),
24 S.xSIZE
25 --ORDER BY 1 DESC
26 ) S
27 ORDER BY TIME DESC,
28 xSIZE ASC
29 /
SELECT TRUNC(S.TIME, 'HH24') TIME,
ERROR at line 18:
ORA-00979: not a GROUP BY expression
SQL> SELECT TIME,
2 xSIZE,
3 (SOLD - NVL(
4 (
5 SELECT SUM(S1.SOLD)
6 FROM STATISTICS S1
7 WHERE S1.xSIZE = S.xSIZE
8 AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
9 AND TO_CHAR(S1.TIME, 'HH24') != '23'
10 AND S1.xSIZE IS NOT NULL
11 GROUP BY TRUNC(S1.TIME, 'HH24'),
12 S1.xSIZE
13 ),
14 0
15 )
16 ) SOLD
17 FROM (
18 SELECT TRUNC(S.TIME, 'HH24') TIME,
19 S.xSIZE,
20 SUM(S.SOLD) SOLD,
21 ROW_NUMBER() OVER(ORDER BY SUM(S.SOLD)) RN
22 FROM STATISTICS S
23 WHERE S.xSIZE IS NOT NULL
24 GROUP BY TRUNC(S.TIME, 'HH24'),
25 S.xSIZE
26 --ORDER BY 1 DESC
27 ) S
28 ORDER BY TIME DESC,
29 xSIZE ASC
30 /
TIME XS SOLD
20-SEP-11 L 9
20-SEP-11 M 0
20-SEP-11 XL 11
20-SEP-11 L 51
20-SEP-11 M 13
20-SEP-11 XL 10
6 rows selected.
SQL> Or use subquery factoring (WITH clause) + undocumented hint MATERIALIZE:
SQL> WITH S AS (
2 SELECT /*+ MATERIALIZE */ TRUNC(S.TIME, 'HH24') TIME,
3 S.xSIZE,
4 SUM(S.SOLD) SOLD
5 FROM STATISTICS S
6 WHERE S.xSIZE IS NOT NULL
7 GROUP BY TRUNC(S.TIME, 'HH24'),
8 S.xSIZE
9 --ORDER BY 1 DESC
10 )
11 SELECT TIME,
12 xSIZE,
13 (SOLD - NVL(
14 (
15 SELECT SUM(S1.SOLD)
16 FROM STATISTICS S1
17 WHERE S1.xSIZE = S.xSIZE
18 AND TRUNC(S1.TIME, 'HH24') + 1/24 = S.TIME
19 AND TO_CHAR(S1.TIME, 'HH24') != '23'
20 AND S1.xSIZE IS NOT NULL
21 GROUP BY TRUNC(S1.TIME, 'HH24'),
22 S1.xSIZE
23 ),
24 0
25 )
26 ) SOLD
27 FROM S
28 ORDER BY TIME DESC,
29 xSIZE ASC
30 /
TIME XS SOLD
20-SEP-11 L 9
20-SEP-11 M 0
20-SEP-11 XL 11
20-SEP-11 L 51
20-SEP-11 M 13
20-SEP-11 XL 10
6 rows selected.
SQL> SY. -
Grouping error in Oracle's analytic function PERCENTILE_CONT()
Hi,
I have a question regarding the usage of Oracle's analytic function PERCENTILE_CONT(). The underlying time data in the table is of hourly granularity and I want to fetch average, peak values for the day along with 80th percentile for that day. For the sake of clarification I am only posting relevant portion of the query.
Any idea how to rewrite the query and achieve the same objective?
SELECT TRUNC (sdd.ts) AS ts,
max(sdd.maxvalue) AS max_value, avg(sdd.avgvalue) AS avg_value,
PERCENTILE_CONT(0.80) WITHIN GROUP (ORDER BY sdd.avgvalue ASC) OVER (PARTITION BY pm.sysid,trunc(sdd.ts)) as Percentile_Cont_AVG
FROM XYZ
WHERE
XYZ
GROUP BY TRUNC (sdd.ts)
ORDER BY TRUNC (sdd.ts)
Oracle Error:
ERROR at line 5:
ORA-00979: not a GROUP BY expressionYou probably mixed up the aggregate and analytical versin of PERCENTILE_CONT.
The below should work, but i dont know if it produces the desireed results.
SELECT TRUNC (sdd.ts) AS ts,
max(sdd.maxvalue) AS max_value, avg(sdd.avgvalue) AS avg_value,
PERCENTILE_CONT(0.80) WITHIN GROUP (ORDER BY sdd.avgvalue ASC) as Percentile_Cont_AVG
FROM XYZ
sorry, what is this where clause for??
WHERE
XYZ
GROUP BY TRUNC (sdd.ts)
ORDER BY TRUNC (sdd.ts) Edited by: chris227 on 26.03.2013 05:45 -
Hi guys i need some help with the logic. As an example, i have table with Account and product columns. So each Account can have multiple products. Now i need SQL to see Accounts that have only Product.
One way of doing it is by doing a groupby and having count(Account) =1. I need an alternative for this. Please help me with your ideas. Thanks in advance.Alberto Faenza wrote:
Is there any reason why you don't want to use group by or just your curiosity to find alternatives?Simple case would be: "I need to select everything from account table where account has multiple products". And between:
SELECT *
FROM YOUR_TABLE
WHERE ACCOUNT IN (
SELECT ACCOUNT,
FROM YOUR_TABLE
GROUP BY ACCOUNT
HAVING COUNT(*) > 1
/and
SELECT *
FROM (
SELECT ACCOUNT,
COUNT(*) OVER(PARTITION BY ACCOUNT) CNT
FROM YOUR_TABLE
WHERE CNT > 1
/I prefer the latter.
SY. -
We have to use a group by into a request from an oracle database :
SELECT SUBSTR(ETETAFI,0,6)
||'0'
||' '
||' '
||MAX(SUBSTR(ETETAFI,13,35))
||RPAD(TO_CHAR(SUM(TO_NUMBER(SUBSTR(ETETAFI,48,16)))),16,' ')
||RPAD(TO_CHAR(SUM(TO_NUMBER(SUBSTR(ETETAFI,64,16)))),16,' ')
||RPAD(TO_CHAR(SUM(TO_NUMBER(SUBSTR(ETETAFI,80,16)))),16,' ')
||RPAD(TO_CHAR(SUM(TO_NUMBER(SUBSTR(ETETAFI,96,16)))),16,' ')
FROM JDEDATA900.F7409FOW GROUP BY SUBSTR(ETETAFI,0,6)
Do you know how to do that as the table JDEDATA900.F7409FOW is our source.
Thanks.To use GROUP BY, when you map any column with an aggregate function, ODI will automatically generate a group by on all other columns which are mapped, but without an aggregate function.
Maybe you are looking for
-
Does anyone know how to turn off the notifications that pop up in the upper right corner telling you that you have just changed from one configuration to another -- e.g. changing from tent mode to tablet mode? Solved! Go to Solution.
-
Adobe Updater6 is very slow downloading updates
Hi, I just got a new Win 7 64 bit machine and installed my copy of Photoshop CS4. The Adobe Updater is downloading the auto updates very very slowly - tells me it will take over 200 hours to update 260 odd MB of updates. I have a 4Mb/sec ADSL connect
-
Where is the 64-bit version?
It is a bit silly that there still doesn't seem to be a 64-bit version of Skype available for Linux. Do they even produce 32-bit hardware nowadays and are Windows only running 32-bit? What ever the reason - I do not care. I just want my install to be
-
How to keep the focus on the inputtext field.
Hi, I'm using jdev 11.1.2.0 I have two inputtext fields. when i tabout from firstinputtextfield , i'm calling a javascript to set focus on to the second textinput field. this is working fine. Second textfield has one server listner onblur event. When
-
I bought Adobe creative suite 6 ( Student Edition ) for Windows? Can I install the programs on Mac as well?