Use of Sub Query in a filter is throwing error
Hi
I am using a sub query in a filter which throws me the following error in owb 9i.
PLS 00405 : Subquery cannot be used in this context.
But the use of subquery works fine in a joiner operator.
Use of Sub Query in a filter works fine in owb 2i.
Could any one please help me.
Thanks in Advance
Nanda Kishore
Nanda,
Please wrap the source table in a view containing the subquery and then use the view as a source rather than use the subquery in the filter.
Regards:
Igor
Similar Messages
-
Using correlated sub-query in update stmt
Hi,
I just need a help to fine tune this below query. The following query is throwng connection reset error.
UPDATE ftmmgr.RECON_TEMP RT SET PRCS_STAT_F =
(CASE WHEN (SELECT COUNT(1) as count FROM ftmmgr.INVC_ITEM ii WHERE ii.INVC_SEQ_I = RT.INVC_SEQ_I) =
(SELECT COUNT(1) as count FROM ftmmgr.RECON_TEMP rtr WHERE rtr.INVC_SEQ_I = RT.INVC_SEQ_I AND
UPPER(TRIM(SLF_RECON_F)) = 'N' AND UPPER(TRIM(SRC_SYS_C)) = 'FTM')
THEN 'F' ELSE 'O' END)
Thanks in advancevasanthskr wrote:
Hi,
I just need a help to fine tune this below query. The following query is throwng connection reset error.
UPDATE ftmmgr.RECON_TEMP RT SET PRCS_STAT_F =
(CASE WHEN (SELECT COUNT(1) as count FROM ftmmgr.INVC_ITEM ii WHERE ii.INVC_SEQ_I = RT.INVC_SEQ_I) =
(SELECT COUNT(1) as count FROM ftmmgr.RECON_TEMP rtr WHERE rtr.INVC_SEQ_I = RT.INVC_SEQ_I AND
UPPER(TRIM(SLF_RECON_F)) = 'N' AND UPPER(TRIM(SRC_SYS_C)) = 'FTM')
THEN 'F' ELSE 'O' END)
Thanks in advanceNo database version provided?
No table structures povided?
No example data provided?
No explanation as to what you're trying to achieve?
As for tuning....
No explain plans provided?
No trace provided?
No details of indexes or statistics, cardinality, selectivity or skew of data provided?
Read these threads:
[How to post a SQL statement tuning request|http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0]
[When your query takes too long...|http://forums.oracle.com/forums/thread.jspa?messageID=1812597#1812597]
It's also a good idea to provide a nicely formatted version of your code so people can read it, using {noformat}{noformat} tags around it...UPDATE ftmmgr.RECON_TEMP RT
SET PRCS_STAT_F =
(CASE WHEN (SELECT COUNT(1) as count
FROM ftmmgr.INVC_ITEM ii
WHERE ii.INVC_SEQ_I = RT.INVC_SEQ_I)
=
(SELECT COUNT(1) as count
FROM ftmmgr.RECON_TEMP rtr
WHERE rtr.INVC_SEQ_I = RT.INVC_SEQ_I
AND UPPER(TRIM(SLF_RECON_F)) = 'N'
AND UPPER(TRIM(SRC_SYS_C)) = 'FTM')
THEN 'F'
ELSE 'O'
END) -
Multi-row sub query returns ORA-00904 :invalid identifier error
I am creating a report from two tables that I am not joining. I want a single line for every row in table1 that meets a date range. Table2 can contain none or many rows for each recored in table1. I want to get up to two fields from table2.
I was using a case statement to check if there was data and then an in-line query or subquery. Once again, the idea is to have a single line on the report for each table1 record.
I get this error with the code below. It seems the nested multi-row subquery can not see the a.cr_mas_cr_no identifier.
ORA-00904: "a"."cr_mas_cr_no": invalid identifier
Any help is greatly appreciated,
Sam
select
a.cr_mas_cr_no "CRNO", a.cr_mas_type "TYPE", a.cr_mas_status "CR Status",
a.cr_mas_date_logged "Logged date", a.CR_REL_REQ_APP_DATE "RTP approved",a.CR_REL_REQ_RTP_DATE "RTP Date",
a.cr_accepted_date "Complete", a.cr_mas_submitted_by "Requester",
select doc_user FROM crrm_cr_documents WHERE doc_cr_number =a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'BD' ) "Bus Design",
(select doc_user FROM crrm_cr_documents WHERE doc_cr_number = a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'TD' ) "Tech Design",
(select doc_user FROM crrm_cr_documents WHERE doc_cr_number = a.cr_mas_cr_no and rownum = 1 and DOC_TYPE = 'TE' ) "User acceptance test",
case
when (select count(appr_user) from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') > 0
then (select appr_user from (select * from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
end
"RTP #1",
case
when (select count(appr_user) from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') > 1
then (select appr_user from (select * from crrm_cr_approvals where appr_cr_no = a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 2)
end
"RTP #2",
a.CR_REL_REQ_RTP_BY "Released by",
a.CR_ACCEPTED_BY "Post RTP User Acceptance",
a.cr_mas_title "Title", a.cr_mas_id "ID"
from
crrm_crmaster a
where
(a.CR_REL_REQ_RTP_DATE >= :P1109_BEGDATE and (a.CR_REL_REQ_RTP_DATE <= :P1109_ENDDATE) and
(a.cr_mas_status = 'Complete' or (a.cr_mas_status = 'Release Approved'and a.CR_REL_REQ_APP_DATE < :P1109_ENDDATE))
Message was edited by:
slavanawayIceman,
Thanks for the reply I will try your suggestion.
I will try and explain why I think two subqueries (an in-line query with a subquery?) are required. I will use the creation of the column RTP #1 as the example as the RTP #2 column is only different in the rownum selected.
Looking only at the lines that fail, here is my analysis. (If I rem out the two case lines the query runs, I just don't get two columns of data I need.) I will only examine the first case as the second is changed to extract the second approval via the rownum = 2 criteria. The first statement checks there is at least one RTP approval stored for the request and then gets the user who approved the request if the test is true.
case when
(select count(appr_user) from crrm_cr_approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP') > 0
then
The above part works fine and the correct count of approvals is returned.
(select appr_user from (select * from crrm_cr_approvals where appr_cr_no=a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
end
"RTP #1",
I moved the parenthesis to the correct location. There can be multiple approvals for a given parent record. Some parent records need one, some need two approvals. If I replace
(select appr_user from (select * from crrm_cr_approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP') where rownum = 1)
with
(select appr_user from approvals where appr_cr_no =a.cr_mas_cr_no and appr_type = 'RTP' and rownum = 1)
The correct result is returned because it returns exactly one row as rownum=1 limits the query. When rownum = 2 then the query returns null as the rownum never gets to two as the rownum column is built via the set created by the second subquery.
The subquery builds a set of approvals for a specific "cr_no" and appr_type of "RTP". the outer query then looks at the rownum of the second query
Here is where I got the rownum information from;
http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
So here is what I think is happening;
1. Main query From and Where are processed. This should provide the "set" for the query
2.The from subqueries for RTP #1 and RTP #2 should be able to access the a.cr_mas_cr_no field and build a set from the approvals table.
3.The RTP #1/2 subquery (inline maybe a better description?) would then get the correct row from the from subquery.
The error "invalid identifier" refers to the a.cr_mas_cr_no field. I assume it means it can not resolve the table alias inside the subquery.
So maybe your grouping would help, I will try.
Sam -
Need to include duplicate records in sub query
Hi All,
I am using the following query and i am getting error message that your sub query return dupliate records and throwing error. Actually i need these duplicate records for my report. I want to get records for
whole year like
JAN FEB MARCH .. ... ...
and idea how i can achieve this task and my query is as follows
select pmnum
,SITEID,
(select description from locations where pm.location = locations.location and pm.siteid=locations.siteid) as site,
(select description from commodities where commodities.commodity= pm.commoditygroup) as workcategory,
description, (select wonum from workorder where workorder.pmnum = pm.pmnum
and targstartdate < '2013-02-01') as jan,
(select wonum from workorder where workorder.pmnum = pm.pmnum and
workorder.status<>'CAN' and targstartdate >= '2013-02-01' and
targstartdate < '2013-03-01') as feb,
(select wonum from workorder where workorder.pmnum = pm.pmnum and
workorder.status<>'CAN' and targstartdate >= '2013-03-01' and
targstartdate < '2013-04-01') as mar
(select name from companies where companies.company = pm.vendor) as contractor
from pm where ((PM.siteid = 'AAA'))Subqueries in the SELECT column list must return a scalar value (single row, single column). If you need multiple rows returned, use a join instead. But you need to consider what will happen when more than one row is returned by more than one
of the joins because these are correlated with the pm table row but not each other. For example, let's say you have a single row returned from "pm" matching 5 sites and 3 workcategories. This will result in 15 rows being returned for the single
pm row.
Below is an untested example.
SELECT
pmnum
,SITEID
,locations.description as site
,commodities.description as workcategory
,pm.description
,workorder_jan.wonum AS jan
,workorder_feb.wonum AS feb
,workorder_mar.wonum AS mar
,companies.name AS contractor
FROM dbo.pm
LEFT JOIN dbo.locations ON pm.location = locations.location
AND pm.siteid=locations.siteid
LEFT JOIN dbo.commodities ON commodities.commodity = pm.commoditygroup
LEFT JOIN dbo.workorder AS workorder_jan ON workorder_jan.pmnum = pm.pmnum
AND workorder_jan.targstartdate < '2013-02-01'
LEFT JOIN dbo.workorder AS workorder_feb ON workorder_feb.pmnum = pm.pmnum
AND workorder_feb.status <> 'CAN'
AND workorder_feb.targstartdate >= '2013-02-01'
AND workorder_feb.targstartdate < '2013-03-01'
LEFT JOIN dbo.workorder AS workorder_mar ON workorder_mar.pmnum = pm.pmnum
AND workorder_mar.status <> 'CAN'
AND workorder_mar.targstartdate >= '2013-03-01'
AND workorder_mar.targstartdate < '2013-04-01'
LEFT JOIN dbo.companies ON companies.company = pm.vendor
WHERE pm.siteid = 'AAA';
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
Calculation based on sub query
Is it possible to base a calculation on a sub query whereby both the calculation sheet and sub query sheet reside on same discoverer workbook?
This is possible in MS Excel whereby information from one tab can be used in another tab. I am using Discoverer 3.1.44Hi
I'm afraid that Discoverer's use of sub queries is restricted to only using a sub query as a means of further controlling the data that is pulled back.
It is not possible to use data from a sub query in a calculation, only in a condition. It also makes no difference which version of Discoverer you have because this mode of operation remains the same no matter what version you have (even 10g!!)
Hope this helps
Regards
Michael -
Number of Execution of Sub-Query
Hi,
Let suppose we have a SQL which has a sub-query in the filter NOT IN clause as shown below. I wish to know that whether for each record from Table_1 (T1),
the inner/filter SQL will execute
or
It will execute only once for that session (All the records from T1).
Meaning: Let suppose Table_1 has 5 Million records. So whether the filter/sub-query will be executed 5 Million times by Oracle Engine or It will be executed only once.
SQL:
SELECT T1.C1, T1.C2, T2.C3 FROM Table_1 T1
INNER JOIN
Table_2 T2
ON T1.C1=T2.C1
WHERE T1.C2 = 0 AND
T1.C4 NOT IN(SELECT DISTINCT COLUMN_12 FROM TABLE_3 WHERE COLUMN_13 = 'VALUE');
Best Regards,
MayurIt depends on the execution plan. NOT IN can be converted to NOT EXISTS, it can be converted to an ANTI-JOIN.
If it's converted to a hash (or merge) ANTI-JOIN the subquery is (effectively) executed once, if it's converted to a nested loop anti-join it's (effectively) executed once per row in the driving rowsource. If it's converted to a NOT EXISTS filter subquery it may be executed as much as once per row in the driving row source, it may be executed as little as once per distinct value in the driving row source. (See http://jonathanlewis.wordpress.com/2006/11/06/filter-subqueries/ for an example of the FILTER subquery count
Regards
Jonathan Lewis -
A simple sub query
I have a table called instrument with a field called id_inst
instrument
id_inst
0000203
There is another table called instrument_xref
instrument_xref
id_inst id_inst_xref
0000203 890000
I want to use a sub query that will give the output
id_inst id_inst_xref
0000203 890000
The subquery I am using is not working
Select i.id_inst,insx.id_inst_xref
from instrument i,instrument_xref insx
where i.id_inst = (Select ???
Can some one please help?You don't need a subquery :
SQL> Select i.id_inst,insx.id_inst_xref
2 from instrument i,instrument_xref insx
3* where i.id_inst = insx.id_inst;anyway :
SQL> Select i.id_inst,insx.id_inst_xref
2 from instrument i,instrument_xref insx
3* where i.id_inst = (select id_inst from instrument_xref); -
Dear Sir/Madam
I'm a student who is interested in Oracle Database and
I have some problems with JOIN and Sub-query.
I hope so many of you could help me.
if i use JOIN without sub-query, may it be faster or not?
SELECT field1, field2 FROM tableA INNER JOIN tableB
if i use JOIN with sub-query, may it be faster or not?
SELECT field1,field2,field3 FROM tableA INNER JOIN (SELECT field1,field2 FROM tableB)
Thanks in advance!Hi,
fac30d8e-74d3-42aa-b643-e30a3780e00f wrote:
Dear Sir/Madam
I'm a student who is interested in Oracle Database and
I have some problems with JOIN and Sub-query.
I hope so many of you could help me.
if i use JOIN without sub-query, may it be faster or not?
SELECT field1, field2 FROM tableA INNER JOIN tableB
if i use JOIN with sub-query, may it be faster or not?
SELECT field1,field2,field3 FROM tableA INNER JOIN (SELECT field1,field2 FROM tableB)
Thanks in advance!
As the others have said, the execution plan will give you a better idea about which is faster.
If you're trying to see how using (or not using) a sub-query affects performance, make the rest of the queries as similar as possible. For example, include field3 in both queries, or ignore field3 in both queries.
In this particular case, I guess the optimizer would do the same thing either way, but that's just a guess. I can't see your execution plans.
In general, simpler code is faster, and better in other ways, too. In this case
tableB
is simpler than
(SELECT field1, field2 FROM tableB)
Why do you want a sub-query in this example? -
Sub-query question, looking up value within a query
I have a situation to lookup prior period value within the same query. I tried to use a sub-query but getting a syntax error:
SELECT [VALUE-BAND_ACCT].GLSeq, [VALUE-BAND_ACCT].NUM_SITES, [VALUE-BAND_ACCT].SGMNT1,
[VALUE-BAND_ACCT].SGMNT2, [VALUE-BAND_ACCT].LOB$, [VALUE-BAND_ACCT].PERIOD, [VALUE-BAND_ACCT].RECUR, [VALUE-BAND_ACCT].PROMOTED, [VALUE-BAND_ACCT].COMB_REV_GRS, [VALUE-BAND_ACCT].COMB_REV_NET, [VALUE-BAND_ACCT].ARPSg_ACCT, [VALUE-BAND_ACCT].ARPSn_ACCT,
[VALUE-BAND_ACCT].COMB_VALUE_BAND,
(SELECT [VALUE-BAND_ACCT].COMB_VALUE_BAND
FROM VALUE-BAND_ACCT
WHERE [VALUE-BAND_ACCT].PERIOD = DateSerial(Year([VALUE-BAND_ACCT].PERIOD), Month([VALUE-BAND_ACCT].PERIOD)-1, 1)) AS PRIOR_VALUE_BAND
FROM VALUE-BAND_ACCT;
Appreciating help.Try this:
SELECT [VALUE-BAND_ACCT].GLSeq, [VALUE-BAND_ACCT].NUM_SITES, [VALUE-BAND_ACCT].SGMNT1,
[VALUE-BAND_ACCT].SGMNT2, [VALUE-BAND_ACCT].LOB$, [VALUE-BAND_ACCT].PERIOD,
[VALUE-BAND_ACCT].RECUR, [VALUE-BAND_ACCT].PROMOTED, [VALUE-BAND_ACCT].COMB_REV_GRS,
[VALUE-BAND_ACCT].COMB_REV_NET, [VALUE-BAND_ACCT].ARPSg_ACCT,
[VALUE-BAND_ACCT].ARPSn_ACCT, [VALUE-BAND_ACCT].COMB_VALUE_BAND,
[VALUE-BAND_ACCT_1].COMB_VALUE_BAND AS PRIOR_VALUE_BAND
FROM [VALUE-BAND_ACCT] INNER JOIN [VALUE-BAND_ACCT] AS [VALUE-BAND_ACCT_1]
ON [VALUE-BAND_ACCT].GLSeq = [VALUE-BAND_ACCT_1].GLSeq AND
[VALUE-BAND_ACCT].[LOB$] = [VALUE-BAND_ACCT_1].[LOB$]
WHERE [VALUE-BAND_ACCT_1].PERIOD =
DateSerial(Year([VALUE-BAND_ACCT].PERIOD), Month([VALUE-BAND_ACCT].PERIOD)-1, 1)
or
SELECT [VALUE-BAND_ACCT].GLSeq, [VALUE-BAND_ACCT].NUM_SITES, [VALUE-BAND_ACCT].SGMNT1,
[VALUE-BAND_ACCT].SGMNT2, [VALUE-BAND_ACCT].LOB$, [VALUE-BAND_ACCT].PERIOD,
[VALUE-BAND_ACCT].RECUR, [VALUE-BAND_ACCT].PROMOTED, [VALUE-BAND_ACCT].COMB_REV_GRS,
[VALUE-BAND_ACCT].COMB_REV_NET, [VALUE-BAND_ACCT].ARPSg_ACCT,
[VALUE-BAND_ACCT].ARPSn_ACCT, [VALUE-BAND_ACCT].COMB_VALUE_BAND,
[VALUE-BAND_ACCT_1].COMB_VALUE_BAND AS PRIOR_VALUE_BAND
FROM [VALUE-BAND_ACCT] INNER JOIN [VALUE-BAND_ACCT] AS [VALUE-BAND_ACCT_1]
ON [VALUE-BAND_ACCT].GLSeq = [VALUE-BAND_ACCT_1].GLSeq AND
[VALUE-BAND_ACCT].[LOB$] = [VALUE-BAND_ACCT_1].[LOB$] AND
[VALUE-BAND_ACCT_1].PERIOD =
DateSerial(Year([VALUE-BAND_ACCT].PERIOD), Month([VALUE-BAND_ACCT].PERIOD)-1, 1)
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
Filter query with sub query using Dropdown box
Dear Community,
I have 2 queries
1. Main Query with 2 fields: Project | Project value
2. Sub Query with 2 fields: Project group | Project
Project group can be belonging to number of projects and project can be belong to number of project group (Many to Many).
My customer wants the main query will open without any filtering.
When I choose project group from WAD dropdown box, the main query will filtering all the projects that belong to the project group.
I create WAD; define dropdown box as sub query, and Analysis as main query.
In the dropdown box I choose "data binding" char and create command "set selection state by binding" (project to project) but it doesnu2019t work.
I also try to do this by Replacement Path in the main query, but the variable requires the attribute will be ready for input.
Thanks a lot
YanivI am not sure about your comments on replacement path variable. Without having tried it, here is what I would have attempted:
The main query needs to use a replacement path variable for Project that is replaced by the results of the sub-query. Sub-query would have a regular input variable for project group. (as a quick test, if you had one analysis item for main query with variable input enabled, it should prompt you to enter Project group).
Now the drop-down needs to be associated with a javascript function. The javascript function needs to implement command "Set variable state" for the main query data provider to selected value of the drop-down.
The drop-down should be associated with the sub-query data provider, just used to populate the list of values in drop-down. -
Can i use Sub Query Factoring Here ?
Hi;
SQL>SELECT * FROM V$VERSION;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionSQL
select /*+ PARALLEL(det, 4) */ '12062' snapshot_id,det.journal_entry_line_id, det.accounting_date,det.company_code,det.account_number,
det.transaction_id, det.transaction_id_type, det.amount,det.currency_code,det.debit_or_credit,det.category,det.subcategory,det.reference1,det.reference1_type,
det.reference2,det.reference2_type,det.gl_batch_id,det.marketplace_id,det.cost_center,det.gl_product_line,det.location,det.project,det.sales_channel,
det.created_by,det.creation_date,det.last_updated_by,det.last_updated_date,agg.age,last_day(to_date('04/21/2010','MM/DD/YYYY')) snapshot_day
from
select company_code, account_number, transaction_id,
decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,
(last_day(to_date('04/21/2010','MM/DD/YYYY')) - min(z.accounting_date) ) age,sum(z.amount)
from
select /*+ PARALLEL(use, 2) */ company_code,substr(account_number, 1, 5) account_number,transaction_id,
decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,use.amount,use.accounting_date
from financials.unbalanced_subledger_entries use
where use.accounting_date >= to_date('04/21/2010','MM/DD/YYYY')
and use.accounting_date < to_date('04/21/2010','MM/DD/YYYY') + 1
UNION ALL
select /*+ PARALLEL(se, 2) */ company_code, substr(se.account_number, 1, 5) account_number,transaction_id,
decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,se.amount,se.accounting_date
from financials.temp2_sl_snapshot_entries se,financials.account_numbers an
where se.account_number = an.account_number
and an.subledger_type in ('C', 'AC')
) z
group by company_code,account_number,transaction_id,decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type)
having abs(sum(z.amount)) >= 0.01
) agg,
select /*+ PARALLEL(det, 2) */ det.journal_entry_line_id, det.accounting_date, det.company_code, det.account_number, det.transaction_id, decode(det.transaction_id_type, 'CollectionID', 'SettlementGroupID', det.transaction_id_type) transaction_id_type,
det.amount, det.currency_code, det.debit_or_credit, det.category, det.subcategory, det.reference1, det.reference1_type, det.reference2, det.reference2_type,
det.gl_batch_id, det.marketplace_id, det.cost_center, det.gl_product_line, det.location, det.project, det.sales_channel, det.created_by, det.creation_date,
det.last_updated_by, det.last_updated_date
from financials.unbalanced_subledger_entries det
where accounting_date >= to_date('04/21/2010','MM/DD/YYYY')
and accounting_date < to_date('04/21/2010','MM/DD/YYYY') + 1
UNION ALL
select /*+ PARALLEL(det, 2) */ det.journal_entry_line_id, det.accounting_date, det.company_code, det.account_number, det.transaction_id,
decode(det.transaction_id_type, 'CollectionID', 'SettlementGroupID', det.transaction_id_type) transaction_id_type, det.amount, det.currency_code,
det.debit_or_credit, det.category, det.subcategory, det.reference1, det.reference1_type, det.reference2, det.reference2_type, det.gl_batch_id, det.marketplace_id,
det.cost_center, det.gl_product_line, det.location, det.project, det.sales_channel, det.created_by, det.creation_date, det.last_updated_by, det.last_updated_date
from financials.temp2_sl_snapshot_entries det,financials.account_numbers an
where det.account_number = an.account_number
and an.subledger_type in ('C', 'AC')
) det
where agg.company_code = det.company_code
and agg.account_number = substr(det.account_number, 1, 5)
and agg.transaction_id = det.transaction_id
and agg.transaction_id_type = det.transaction_id_type
/Execution Plan
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
| 0 | SELECT STATEMENT | | 12M| 8012M| | 541K (1)| 01:48:21 | | | |
| 1 | PX COORDINATOR | | | | | | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10005 | 12M| 8012M| | 541K (1)| 01:48:21 | Q1,05 | P->S | QC (RAND) |
|* 3 | HASH JOIN BUFFERED | | 12M| 8012M| 1098M| 541K (1)| 01:48:21 | Q1,05 | PCWP | |
| 4 | PX RECEIVE | | 35M| 3992M| | 166K (2)| 00:33:16 | Q1,05 | PCWP | |
| 5 | PX SEND HASH | :TQ10003 | 35M| 3992M| | 166K (2)| 00:33:16 | Q1,03 | P->P | HASH |
| 6 | VIEW | | 35M| 3992M| | 166K (2)| 00:33:16 | Q1,03 | PCWP | |
|* 7 | FILTER | | | | | | | Q1,03 | PCWC | |
| 8 | HASH GROUP BY | | 35M| 4528M| | 166K (2)| 00:33:16 | Q1,03 | PCWP | |
| 9 | PX RECEIVE | | 35M| 4528M| | 166K (2)| 00:33:16 | Q1,03 | PCWP | |
| 10 | PX SEND HASH | :TQ10001 | 35M| 4528M| | 166K (2)| 00:33:16 | Q1,01 | P->P | HASH |
| 11 | HASH GROUP BY | | 35M| 4528M| | 166K (2)| 00:33:16 | Q1,01 | PCWP | |
| 12 | VIEW | | 35M| 4528M| | 164K (1)| 00:33:00 | Q1,01 | PCWP | |
| 13 | UNION-ALL | | | | | | | Q1,01 | PCWP | |
| 14 | PX BLOCK ITERATOR | | 11 | 539 | | 1845 (1)| 00:00:23 | Q1,01 | PCWC | |
|* 15 | TABLE ACCESS FULL | UNBALANCED_SUBLEDGER_ENTRIES | 11 | 539 | | 1845 (1)| 00:00:23 | Q1,01 | PCWP | |
|* 16 | HASH JOIN | | 35M| 2012M| | 163K (1)| 00:32:37 | Q1,01 | PCWP | |
| 17 | BUFFER SORT | | | | | | | Q1,01 | PCWC | |
| 18 | PX RECEIVE | | 21 | 210 | | 2 (0)| 00:00:01 | Q1,01 | PCWP | |
| 19 | PX SEND BROADCAST | :TQ10000 | 21 | 210 | | 2 (0)| 00:00:01 | | S->P | BROADCAST |
|* 20 | TABLE ACCESS FULL| ACCOUNT_NUMBERS | 21 | 210 | | 2 (0)| 00:00:01 | | | |
| 21 | PX BLOCK ITERATOR | | 56M| 2701M| | 162K (1)| 00:32:35 | Q1,01 | PCWC | |
| 22 | TABLE ACCESS FULL | TEMP2_SL_SNAPSHOT_ENTRIES | 56M| 2701M| | 162K (1)| 00:32:35 | Q1,01 | PCWP | |
| 23 | PX RECEIVE | | 35M| 18G| | 82859 (1)| 00:16:35 | Q1,05 | PCWP | |
| 24 | PX SEND HASH | :TQ10004 | 35M| 18G| | 82859 (1)| 00:16:35 | Q1,04 | P->P | HASH |
| 25 | BUFFER SORT | | 12M| 8012M| | | | Q1,04 | PCWP | |
| 26 | VIEW | | 35M| 18G| | 82859 (1)| 00:16:35 | Q1,04 | PCWP | |
| 27 | UNION-ALL | | | | | | | Q1,04 | PCWP | |
| 28 | PX BLOCK ITERATOR | | 11 | 2255 | | 923 (1)| 00:00:12 | Q1,04 | PCWC | |
|* 29 | TABLE ACCESS FULL | UNBALANCED_SUBLEDGER_ENTRIES | 11 | 2255 | | 923 (1)| 00:00:12 | Q1,04 | PCWP | |
|* 30 | HASH JOIN | | 35M| 7514M| | 81936 (1)| 00:16:24 | Q1,04 | PCWP | |
| 31 | PX RECEIVE | | 21 | 210 | | 2 (0)| 00:00:01 | Q1,04 | PCWP | |
| 32 | PX SEND BROADCAST | :TQ10002 | 21 | 210 | | 2 (0)| 00:00:01 | Q1,02 | P->P | BROADCAST |
| 33 | PX BLOCK ITERATOR | | 21 | 210 | | 2 (0)| 00:00:01 | Q1,02 | PCWC | |
|* 34 | TABLE ACCESS FULL | ACCOUNT_NUMBERS | 21 | 210 | | 2 (0)| 00:00:01 | Q1,02 | PCWP | |
| 35 | PX BLOCK ITERATOR | | 56M| 11G| | 81840 (1)| 00:16:23 | Q1,04 | PCWC | |
| 36 | TABLE ACCESS FULL | TEMP2_SL_SNAPSHOT_ENTRIES | 56M| 11G| | 81840 (1)| 00:16:23 | Q1,04 | PCWP | |
Predicate Information (identified by operation id):
3 - access("AGG"."COMPANY_CODE"="DET"."COMPANY_CODE" AND "AGG"."ACCOUNT_NUMBER"=SUBSTR("DET"."ACCOUNT_NUMBER",1,5) AND
"AGG"."TRANSACTION_ID"="DET"."TRANSACTION_ID" AND "AGG"."TRANSACTION_ID_TYPE"="DET"."TRANSACTION_ID_TYPE")
7 - filter(ABS(SUM(SYS_OP_CSR(SYS_OP_MSR(SUM("Z"."AMOUNT"),MIN("Z"."ACCOUNTING_DATE")),0)))>=0.01)
15 - filter("USE"."ACCOUNTING_DATE"<TO_DATE(' 2010-04-22 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "USE"."ACCOUNTING_DATE">=TO_DATE('
2010-04-21 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
16 - access("SE"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
20 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
29 - filter("ACCOUNTING_DATE"<TO_DATE(' 2010-04-22 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "ACCOUNTING_DATE">=TO_DATE(' 2010-04-21
00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
30 - access("DET"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
34 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
This query is failing due to TEMP issue (TEMP SPACE out of space)
My TEMP tablespace is 70GB and no one is using TEMP space while this query is in execution.
PGA=16 GB.
What i can see from execution plan is : Two large resultsets AGG (13Million) and DET (135 Million) is being joined HASH JOIN BUFFERED. Which is getting spilled to TEMP space causing TEMP outage.
Is there any way, i can re-write this query (probably using SUB QUERY FACTORING...WITH CLAUSE) so that reduce two times access to TEMP2_SL_SNAPSHOT_ENTRIES table. TEMP2_SL_SNAPSHOT_ENTRIES is 12 GB non partition table and i cannot use any other filter to restrict rows from this table.Adding more information here :
Inner sub query (Which forms DET-bottom)
select /*+ PARALLEL(det, 2) */ det.journal_entry_line_id, det.accounting_date, det.company_code, det.account_number, det.transaction_id,
decode(det.transaction_id_type, 'CollectionID', 'SettlementGroupID', det.transaction_id_type) transaction_id_type, det.amount, det.currency_code,
det.debit_or_credit, det.category, det.subcategory, det.reference1, det.reference1_type, det.reference2, det.reference2_type, det.gl_batch_id, det.marketplace_id,
det.cost_center, det.gl_product_line, det.location, det.project, det.sales_channel, det.created_by, det.creation_date, det.last_updated_by, det.last_updated_date
from financials.temp2_sl_snapshot_entries det,financials.account_numbers an
where det.account_number = an.account_number
and an.subledger_type in ('C', 'AC');
Plan hash value: 976020246
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
| 0 | SELECT STATEMENT | | 35M| 7514M| 163K (1)| 00:32:47 | | | |
| 1 | PX COORDINATOR | | | | | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10001 | 35M| 7514M| 163K (1)| 00:32:47 | Q1,01 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | 35M| 7514M| 163K (1)| 00:32:47 | Q1,01 | PCWP | |
| 4 | BUFFER SORT | | | | | | Q1,01 | PCWC | |
| 5 | PX RECEIVE | | 21 | 210 | 2 (0)| 00:00:01 | Q1,01 | PCWP | |
| 6 | PX SEND BROADCAST | :TQ10000 | 21 | 210 | 2 (0)| 00:00:01 | | S->P | BROADCAST |
|* 7 | TABLE ACCESS FULL| ACCOUNT_NUMBERS | 21 | 210 | 2 (0)| 00:00:01 | | | |
| 8 | PX BLOCK ITERATOR | | 56M| 11G| 163K (1)| 00:32:45 | Q1,01 | PCWC | |
| 9 | TABLE ACCESS FULL | TEMP2_SL_SNAPSHOT_ENTRIES | 56M| 11G| 163K (1)| 00:32:45 | Q1,01 | PCWP | |
Predicate Information (identified by operation id):
3 - access("DET"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
7 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
Statistics
31 recursive calls
3 db block gets
1634444 consistent gets
1625596 physical reads
636 redo size
1803659818 bytes sent via SQL*Net to client
125054 bytes received via SQL*Net from client
11331 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
56645822 rows processedOther sub query (that forms AGG)
select /*+ PARALLEL(se, 2) */ company_code, substr(se.account_number, 1, 5) account_number,transaction_id,
decode(transaction_id_type, 'CollectionID', 'SettlementGroupID', transaction_id_type) transaction_id_type,se.amount,se.accounting_date
from financials.temp2_sl_snapshot_entries se,financials.account_numbers an
where se.account_number = an.account_number
and an.subledger_type in ('C', 'AC');
Plan hash value: 976020246
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
| 0 | SELECT STATEMENT | | 35M| 2012M| 163K (1)| 00:32:37 | | | |
| 1 | PX COORDINATOR | | | | | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10001 | 35M| 2012M| 163K (1)| 00:32:37 | Q1,01 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | 35M| 2012M| 163K (1)| 00:32:37 | Q1,01 | PCWP | |
| 4 | BUFFER SORT | | | | | | Q1,01 | PCWC | |
| 5 | PX RECEIVE | | 21 | 210 | 2 (0)| 00:00:01 | Q1,01 | PCWP | |
| 6 | PX SEND BROADCAST | :TQ10000 | 21 | 210 | 2 (0)| 00:00:01 | | S->P | BROADCAST |
|* 7 | TABLE ACCESS FULL| ACCOUNT_NUMBERS | 21 | 210 | 2 (0)| 00:00:01 | | | |
| 8 | PX BLOCK ITERATOR | | 56M| 2701M| 162K (1)| 00:32:35 | Q1,01 | PCWC | |
| 9 | TABLE ACCESS FULL | TEMP2_SL_SNAPSHOT_ENTRIES | 56M| 2701M| 162K (1)| 00:32:35 | Q1,01 | PCWP | |
Predicate Information (identified by operation id):
3 - access("SE"."ACCOUNT_NUMBER"="AN"."ACCOUNT_NUMBER")
7 - filter("AN"."SUBLEDGER_TYPE"='AC' OR "AN"."SUBLEDGER_TYPE"='C')
Statistics
31 recursive calls
3 db block gets
1634444 consistent gets
1625596 physical reads
592 redo size
1803659818 bytes sent via SQL*Net to client
125054 bytes received via SQL*Net from client
11331 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
56645822 rows processed -
Sub Query or Use Result of Query on OLAP BW Universe ?
Dear All,
Could you use in Webi report :
1 ) Sub Query ? I activate the option with Designer but button is still in grey...
2 ) Result of query on filter panel ? The button is still in grey
Regards
CédricHi ,
I do it before my initial post... without success.
I already use Sub Query in relational database, but with OLAP BW universe, I can't use actually...
I am searching info, solution,...
Thanks
Cédric -
Hi,
I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
http://server/pages/Default.aspx?Title=Arup&Title=Ratan
But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
I have followed the
http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
Please suggest me.
Thanks | Arup
THanks! Arup R(MCTS)
SucCeSS DoEs NOT MatTer.Hi DH, sorry for not being clear.
It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
(or a Performance Point Dashboard etc.) and you insert it into your page and add
a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
with multiple values for one parameter. If you have any more questions let me know. See you, Ingo -
How to use sub query in CAML in splist
hi,
want to know whether any sub query functionality can be achieved in splist/sp doc lib using CAML designer 2013/ query builder. also inner joins need to be implemented as pe rmy requirement.
if caml designer is not supported, whats the allternative way of doing this?
can LINQ to SP be used? if yes, can anyone pls roivde how to implement the same
help is appreciatedYou can use the let keyword to scope a variable containing the result of your subquery.
However, it depends on the LINQ provider as to whether or not it can understand the command.
For example, you can create the sample like this
var result = (from p in productInQuery
join o in orderInfoQuery on p.refNo equals o.refNo
join t in productOutQuery on p.no equals t.productInNo into productIn
from t in productIn.DefaultIfEmpty()
let dateOut = (from m in orderInfoQuery where m.refNo == t.refNo select m.processData).FirstOrDefault()
orderby o.processDate descending
select new
modelNo = x.modelNo,
qty = p.qty,
dateIn = o.processDate,
dateOut = dateOut
https://www.youtube.com/watch?v=N3K0h6GDwW4
For more info, check this
http://msdn.microsoft.com/en-us/library/ee539975.aspx -
Please suggest a select query / sub query with out using any subprograms or
source table: Three columns ORIGIN, DESTINATION,MILES
Origin Destination Miles
Sydney Melbourne 1000
Perth Adelaide 3000
Canberra Melbounre 700
Melbourne Sydney 1000
Brisbane Sydney 1000
Perth Darwin 4000
Sydney Brisbane 1000
out put :Three columns ORIGIN, DESTINATION,MILES
Duplicate routes are to be ignored so the output is
Origin Destination Miles
Sydney Melbourne 1000
Perth Adelaide 3000
Canberra Melbounre 700
Brisbane Sydney 1000
Perth Darwin 4000
Please suggest a select query / sub query with out using any subprograms or functions/pkgs to get the out put table.Hi,
user9368047 wrote:
... Please suggest a select query / sub query with out using any subprograms or functions/pkgs to get the out put table.Why? If the most efficient way to get the results you want involves using a function, why wouldn't you use it?
Here's one way, without any functions:
SELECT a.*
FROM source_table a
LEFT OUTER JOIN source_table b ON a.origin = b.destination
AND a.destination = b.origin
AND a.miles = b.miles
WHERE b.origin > a.origin -- Not b.origin > b.origin
OR b.origin IS NULL
;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
Edited by: Frank Kulash on Nov 6, 2012 7:39 PM
Corrected WHERE clause after MLVrown (below)
Maybe you are looking for
-
Selling on Oracle support services
Hi Everyone My name is Ajit. I'm new to this forum. Infact I'm new on the Oracle Technology. I've just joined a company which provides support services on Oracle technology. We focus on RDBMS right now and we are also an Oracle Partner. I'd like to k
-
Playback of purchased music skips, wrong speed, etc.
Ok, this was going to be a question, but maybe it will help diagnose future problems. Software: iTunes 6.0.4 (3) FireFox 1.5.0.3 (most recently updated) OS 10.4.6 Hardware: PowerMac G5 dual processor 2Ghz recently added 2GB of RAM for total of 2.5GB
-
Finder filenames represent adjacent file - whats happening
New tech problem for me: In either of the vertical stacked file listing (list and columns view) finder is mis-representing the file by showing the icon with the name to the adjacent file. It is also occasionally naming the adjacent file by the same n
-
I am using an iMac G5, 10.4.8, with Quicktime 7.1.3 and for some reason I cannot hear any quicktime movies played. The video portion works fine, just not the sound. I've gone into all of the sound system files and my microphone and speakers work fine
-
Safari Blue Progress Bar and Yahoo Webmail
I have noticed that using Safari with Yahoo Webmail yields the odd behavior that when you attach a file from your computer, the blue progress bar up in the middle of the safari window freezes at some point. Everything works, but until you reset safar