Needs Query Optimization
Hi All
I have the below query - which is a great performance killer.
SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG
A~ERDAT A~ERZET A~PSTYV D~AUART E~ETTYP
E~EDATU
INTO TABLE INT_FIN
FROM VBAP AS A
INNER JOIN VBAK AS D ON D~VBELN EQ A~VBELN AND
D~MANDT EQ A~MANDT
INNER JOIN VBEP AS E ON E~VBELN EQ A~VBELN AND
E~POSNR EQ A~POSNR AND
E~MANDT EQ A~MANDT
WHERE A~VBELN IN s_VBELN AND
D~auart in s_auart AND
D~vkorg in s_vkorg AND
D~vbtyp eq 'C' AND
( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
A~ABGRU EQ SPACE AND
A~MTVFP IN R_MTVFP AND
A~PRCTR IN R_PRCT AND
E~ETENR EQ '1'.
SORT INT_FINBY VBELN POSNR ETTYP.
DELETE ADJACENT DUPLICATES FROM INT_FIN COMPARING VBELN POSNR.
CHECK NOT INT_FIN[] IS INITIAL.
SELECT VBELN UVALL CMGST INTO TABLE INT_VBUK
FROM VBUK FOR ALL ENTRIES IN INT_FIN
WHERE VBELN = INT_FIN-VBELN AND
UVALL NE 'A'.
SORT INT_VBUK BY VBELN.
DELETE ADJACENT DUPLICATES FROM INT_VBUK COMPARING VBELN.
How can I optimize this? Please help me to rewrite the same.
Thx
SELECT ...
FROM VBAP AS A
INNER JOIN VBAK AS D ON D~VBELN EQ A~VBELN AND
D~MANDT EQ A~MANDT
INNER JOIN VBEP AS E ON E~VBELN EQ A~VBELN AND
E~POSNR EQ A~POSNR AND
E~MANDT EQ A~MANDT
WHERE A~VBELN IN s_VBELN AND
D~auart in s_auart AND
D~vkorg in s_vkorg AND
D~vbtyp eq 'C' AND
( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
A~ABGRU EQ SPACE AND
A~MTVFP IN R_MTVFP AND
A~PRCTR IN R_PRCT AND
E~ETENR EQ '1'.
What is that ????
( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
adding the aliases would make your statement clearer.
This can not be such a big issue, start with that one.
SELECT ...
FROM VBAP AS A
INNER JOIN VBAK AS D
ON D~MANDT EQ A~MANDT
ON D~VBELN EQ A~VBELN
INNER JOIN VBEP AS E
ON E~MANDT EQ A~MANDT
AND E~VBELN EQ A~VBELN
AND E~POSNR EQ A~POSNR
WHERE A~VBELN IN s_VBELN.
How many records are in s_VBELN? Check number of entries of all three tables
and use the alias of the smallest table.
How does that work?
Add the other conditions, without the complicated thing.
At the end add the complicated condition with the correct aliases.
Siegfried
Similar Messages
-
Hi Everyone:
I have a user on my site who's trying to find information on database query optimization. She's willing to pay $3 to someone who will give her some very basic information. I figured those of you who read this forum would have something handy you could just provide to her. It's not the information she's paying for, but the service of someone retrieving it for her. Would someone take a look? You can find her request here:
http://www.yepic.com/index.php?module=ContReq&hdnRequestID=8
The one problem is you have to register on the site before you can post your response. You just need to give create a username, email and password, though. It's very easy. I'd appreciate someone helping one of my users out.. . . she's trying to avoid the
search taxSearch tax... never heard it put that way. I guess you are trying to avoid the "search engine" tax by advertising your site here? Maybe some one will help you out by answering the request from Corey for Search Engine Optimization. -
Help needed to optimize the query
Help needed to optimize the query:
The requirement is to select the record with max eff_date from HIST_TBL and that max eff_date should be > = '01-Jan-2007'.
This is having high cost and taking around 15mins to execute.
Can anyone help to fine-tune this??
SELECT c.H_SEC,
c.S_PAID,
c.H_PAID,
table_c.EFF_DATE
FROM MTCH_TBL c
LEFT OUTER JOIN
(SELECT b.SEC_ALIAS,
b.EFF_DATE,
b.INSTANCE
FROM HIST_TBL b
WHERE b.EFF_DATE =
(SELECT MAX (b2.EFF_DATE)
FROM HIST_TBL b2
WHERE b.SEC_ALIAS = b2.SEC_ALIAS
AND b.INSTANCE =
b2.INSTANCE
AND b2.EFF_DATE >= '01-Jan-2007')
OR b.EFF_DATE IS NULL) table_c
ON table_c.SEC_ALIAS=c.H_SEC
AND table_c.INSTANCE = 100;To start with, I would avoid scanning HIST_TBL twice.
Try this
select c.h_sec
, c.s_paid
, c.h_paid
, table_c.eff_date
from mtch_tbl c
left
join (
select sec_alias
, eff_date
, instance
from (
select sec_alias
, eff_date
, instance
, max(eff_date) over(partition by sec_alias, instance) max_eff_date
from hist_tbl b
where eff_date >= to_date('01-jan-2007', 'dd-mon-yyyy')
or eff_date is null
where eff_date = max_eff_date
or eff_date is null
) table_c
on table_c.sec_alias = c.h_sec
and table_c.instance = 100; -
Oracle 11g on Linux : Query Optimization issue
Hi guru,
I am facing one query optimization related problem in group by query
Table (10 million Records)
Product(ProductId number,ProductName varchar(100),CategoryId VARCHAR2(38),SubCategoryId VARCHAR2(38))
Index
create index idxCategory on Product (CategoryId,SubCategoryId)
Query1:To find product count for all CategoryId and SubCategoryId
select CategoryId,SubCategoryId,count(*) from Product group by CategoryId,SubCategoryId
Above query is not using index idxCategory and doing table scan which is very costly.
When I fire Query2: select count(*) from Product group by CategoryId,SubCategoryId
then it is properly using index idxCategory and very fast.
Even I specified hint in Query1 but it is not using hint.
Can anybody suggest why oracle is not using index in Query1 and what should I do so that Query1 will use Index.
Thanks in advance.user644199 wrote:
I am facing one query optimization related problem in group by query
Query1:To find product count for all CategoryId and SubCategoryId
select CategoryId,SubCategoryId,count(*) from Product group by CategoryId,SubCategoryId
Above query is not using index idxCategory and doing table scan which is very costly.
When I fire Query2: select count(*) from Product group by CategoryId,SubCategoryId
then it is properly using index idxCategory and very fast.
Even I specified hint in Query1 but it is not using hint.
Can anybody suggest why oracle is not using index in Query1 and what should I do so that Query1 will use Index.The most obvious reason that the table needs to be visited would be that the columns "CategoryId" / "SubCategoryId" can be NULL but then this should apply to both queries. You could try the following to check the NULL issue:
select CategoryId,SubCategoryId,count(*) from Product where CategoryId is not null and SubCategoryId is not null group by CategoryId,SubCategoryId
Does this query use the index?
Can you show us the hint you've used to force the index usage and the EXPLAIN PLAN output of the two queries including the "Predicate Information" section? Use DBMS_XPLAN.DISPLAY to get a proper output, and use the \ tag before and after when posting here to format it using fixed font. Use the "Quote" button in the message editor to see how I used the \ tag here.
Are above queries representing the actual queries used or did you omit some predicates etc. for simplicity?
By the way, VARCHAR2(38) and ...ID as name, are these columns storing number values?
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
Hi All,
I was performing the steps mentioned in Oracle Tutorial"http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/bi/bi11115/biadmin11g_02/biadmin11g.htm#t10"-BI RPD creation.
After Using the AGO function data in the Time series metric(Month Ago Revenue) was null always. I updated the DB features in RPD physical layers by selecting support for time series functions.
After that report started to fail with below error. Please let me know if its a bug and any option to fix it.
Thanks,
Sreekanth
Error
View Display Error
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 46008] Internal error: File server\Query\Optimizer\SmartScheduler\PhysicalRequestGenerator\Src\SQOSPMarkMultiTargetSupport.cpp, line 1680. (HY000)
SQL Issued: SELECT 0 s_0, "Sample Sales"."Time"."Year-L1" s_1, "Sample Sales"."Revenue"."Ago-Year Revenue" s_2, "Sample Sales"."Revenue"."Revenue" s_3 FROM "Sample Sales" FETCH FIRST 65001 ROWS ONLY
RefreshI know that there is no relation between "SampleApp Lite"."D3 Orders (Facts Attributes)"."Order Date", "SampleApp Lite"."D0 Time"."Calendar Date", it's also the same thing in my own RPD.
But as it's working with the 11.1.1.6.2 BP1 version I don't understand why it's not working with 11.1.1.6.9.
Implicit fact column is not set on my repository, but I don't have any request with only dimensional column, so if my understanding is correct I don't need to use it. Also, the problem appears during the check of the repository not in answers.
thanks anyway -
Hi Gurus,
I am preparing for an interview. I need to know about Query Optimization, explain plan, Cost analysis.
Can anyone please give me some reference link or site where i can get step by step details for the above..
It would be really helpfull.
Thanks in advance..
Ameya.RTFM [url http://oraclesvca2.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm]Performance Tuning Guide and Reference
-
HFR - Data Query Optimization Settings
hi
In HFR, in a grid there are Data Query Optimization Settings, can you please help me on the settings property.
Our report fetches data using lot of attributes. When we don't use MDX setting, it fetches very fast, but the alias doesn't come.
However, when we use MDX setting, the alias comes, but the report takes lot of time to run(approx 1 min / row of data fetched)
Can you please guide on the same.
Thankspm wrote:
Hi ,
I am working on below query optimization/Tuning.
SELECT
c_date,
c1,
c2,
c3,
c4,
c5,
c6
FROM tab1
WHERE
ROWNUM <= ¶m
AND ( c_date BETWEEN &date1 AND &date2 )
AND c3 in (
select c3
from tab2
where xxx='abc')
ORDER BY c1, c_date;
Note : ¶m,&date1 ,&date2 are parameters runtime getting from UI code .
tab1 having huge data around 10lacs to crores. and it has range partition on c_date column and subpartiotion on c1 column.
To get best throughput in less time, what i need to do ?
Please do let me know steps to tune/optimize the sql query.Also which hint we can use on sql query to better results.
Thanks in advanced.
PMBefore you start worrying about performance tuning you should worry about the query being incorrect.
WHERE
ROWNUM <= ¶m
AND ( c_date BETWEEN &date1 AND &date2 )
AND c3 in (
select c3
from tab2
where xxx='abc')
ORDER BY c1, c_date;Presumably you want to limit the number of rows with the ROWNUM predicate AFTER the ORDER BY clause is applied.
Please read this and learn how queries are actually processed, I can almost guarantee you this query is not doing what you think it is doing at present.
http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
Cheers, -
Hi All,
I'm doing some bit of study on that portion of Query Optimizer in Oracle9i that is autonomic (I mean it is dynamic and a self learning one).Can anyone give me some pointers to this topic(In fact I doubt whether something like this at all exists, or is still a topic of research); I need some more info on this topic.Some papers or articles may be handy.
Greetings,
Kaustav GhoshalI think u mean CBO (Cost Based Optimizer). If your database is running in "choose" mode so yes, CBO will automaticly optimize your query.
Check the doc here : http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/part1.htm
Fred -
Need query to find out whether exactly 2 columns are used in any index ?
Suppose i have two columns ID and Status (or any number of columns ) belongs to table customer...
Now I want to create below index
Ex. create index test1 on customer (ID , Status )
But before creating this index i want to check that whether there is already index on these 2 columns ? May be by other name ?
Need query for this.
Plz help.Hi Shubhangi,
Your requirement is very difficult to fulfill , i have made an attempt to replicate your reqrmnt & write a query wherein you need to compromise on few things , let us see if it works for you
Supply table_name/owner & Number of column on which you want to find indexes
e.g.
select distinct INDEX_NAME,column_name
from dba_ind_columns
where index_name in (select distinct index_name
from dba_ind_columns
where table_name='&table_name'
and table_owner='&owner'
having count(column_name)=&column_count group by index_name);
Enter value for table_name: ADDRESS
Enter value for owner: ASAP
Enter value for column_count: 2
INDEX_NAME COLUMN_NAME
FKIDX_AD__SF_ST_FO SF_STRUC_FORMAT_NM
FKIDX_AD__SF_ST_FO SF_TYPE_NM
SQL> /
Enter value for table_name: ADDRESS
Enter value for owner: ASAP
Enter value for column_count: 3
INDEX_NAME COLUMN_NAME
FKIDX_AD__SF_ST_FO_1 POSTAL_CD
FKIDX_AD__SF_ST_FO_1 SF_STRUC_FORMAT_NM
FKIDX_AD__SF_ST_FO_1 SF_TYPE_NM
Thanks,
Ajay More
http://moreajays.blogspot.com -
What is query optimization and how to do it.
Hi
What is query optimization?
Any link can any one provide me so that i can read and learn the techniques.
Thanks
Elias MaliackalTHis is an excellent place to start: When your query takes too long ...
-
Reg Query Optimization - doubts..
Hi Experts,
This is related to Blog by Mr Prakash Darji regarding "Query Optimization" posted on Jan 26 2006.In this to optimize query Generation of Report is suggested.
I tried this, but I am not sure I am analyzing this correctly.
I collected Stats data before and after Generation of Report.But how to be sure that this is helping me? Did any one has tried this?
What to look for in Stats Data - duration?
But duration would not be absolute parameter as there is factor of "Wait Time, User", so duration may depend on this.
Please help me in this.
Thanks
Gaurav
Message was edited by: GauravAny ideas Experts?
-
SQL Server 2008R2 SP2 Query optimizer memory leak ?
It looks like we are facing a SQL Server 2008R2 queery optimizer memory leak.
We have below version of SQL Server
Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
Jun 28 2012 08:36:30
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
The instance is set MAximum memory tro 20 GB.
After executing a huge query (2277 kB generated by IBM SPSS Clementine) with tons of CASE and a lot of AND/OR statements in the WHERE and CASE statements and muliple subqueries the server stops responding on Out of memory in the internal pool
and the query optimizer has allocated all the memory.
From Management Data Warehouse we can find that the query was executed at
7.11.2014 22:40:57
Then at 1:22:48 we recieve FAIL_PACE_ALLOCATION 1
2014-11-08 01:22:48.70 spid75 Failed allocate pages: FAIL_PAGE_ALLOCATION 1
And then tons of below errors
2014-11-08 01:24:02.22 spid87 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:02.22 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:02.22 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:02.30 Server Error: 17312, Severity: 16, State: 1.
2014-11-08 01:24:02.30 Server SQL Server is terminating a system or background task Fulltext Host Controller Timer Task due to errors in starting up the task (setup state 1).
2014-11-08 01:24:02.22 spid74 Error: 701, Severity: 17, State: 123.
2014-11-08 01:24:02.22 spid74 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:13.22 Server Error: 17312, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:13.22 spid87 Error: 701, Severity: 17, State: 123.
2014-11-08 01:24:13.22 spid87 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:13.22 spid63 Error: 701, Severity: 17, State: 130.
2014-11-08 01:24:13.22 spid63 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:13.22 spid57 Error: 701, Severity: 17, State: 123.
2014-11-08 01:24:13.22 spid57 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:13.22 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:18.26 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:24.43 spid81 Error: 701, Severity: 17, State: 123.
2014-11-08 01:24:24.43 spid81 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:18.25 Server Error: 18052, Severity: -1, State: 0. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:18.25 Server BRKR TASK: Operating system error Exception 0x1 encountered.
2014-11-08 01:24:30.11 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:30.11 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:35.18 spid57 Error: 701, Severity: 17, State: 131.
2014-11-08 01:24:35.18 spid57 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:35.18 spid71 Error: 701, Severity: 17, State: 193.
2014-11-08 01:24:35.18 spid71 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:35.18 Server Error: 17312, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:35.41 Server Error: 17312, Severity: 16, State: 1.
2014-11-08 01:24:35.41 Server SQL Server is terminating a system or background task SSB Task due to errors in starting up the task (setup state 1).
2014-11-08 01:24:35.71 Server Error: 17053, Severity: 16, State: 1.
2014-11-08 01:24:35.71 Server BRKR TASK: Operating system error Exception 0x1 encountered.
2014-11-08 01:24:35.71 spid73 Error: 701, Severity: 17, State: 123.
2014-11-08 01:24:35.71 spid73 There is insufficient system memory in resource pool 'internal' to run this query.
2014-11-08 01:24:46.30 Server Error: 17312, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:51.31 Server Error: 17053, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:51.31 Server Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
2014-11-08 01:24:51.31 Logon Error: 18052, Severity: -1, State: 0. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
Last error message is half an hour after the inital Out of memory at 2014-11-08 01:52:54.03. Then the Instance is completely shut down
From the memory information in the error log we can see that all the memory is consumed by the QUERY_OPTIMIZER
Buffer Pool Value
Committed 2621440
Target 2621440
Database 130726
Dirty 3682
In IO
0
Latched
1
Free
346
Stolen 2490368
Reserved 0
Visible 2621440
Stolen Potential 0
Limiting Factor 17
Last OOM Factor 0
Last OS Error 0
Page Life Expectancy 28
2014-11-08 01:22:48.90 spid75
Process/System Counts Value
Available Physical Memory 29361627136
Available Virtual Memory 8691842715648
Available Paging File 51593969664
Working Set 628932608
Percent of Committed Memory in WS 100
Page Faults 48955000
System physical memory high 1
System physical memory low 0
Process physical memory low 1
Process virtual memory low 0
MEMORYCLERK_SQLOPTIMIZER (node 1) KB
VM Reserved 0
VM Committed 0
Locked Pages Allocated 0
SM Reserved 0
SM Committed 0
SinglePage Allocator 19419712
MultiPage Allocator 128
Memory Manager KB
VM Reserved 100960236
VM Committed 277664
Locked Pages Allocated 21483904
Reserved Memory 1024
Reserved Memory In Use 0
On the other side MDW reports that the MEMORYCLERK_SQLOPTIMIZER increases since the execution of the query up to the point of OUTOF MEMORY, but the Average value is 54.7 MB during that period as can be seen on attached graph.
We have encountered this issue already two times (every time the critical query is executed).Hi,
This does seems to me kind of memory Leak and actually it is from SQL Optimizer which leaked memory from buffer pool so much that it did not had any memory to be allocated for new page.
MEMORYCLERK_SQLOPTIMIZER (node 1) KB
VM Reserved 0
VM Committed 0
Locked Pages Allocated 0
SM Reserved 0
SM Committed 0
SinglePage Allocator 19419712
MultiPage Allocator 128
Can you post complete DBCC MEMORYSTATUS output which was generated in errorlog. Is this the only message in errorlog or there are some more messages before and after it.
select (SUM(single_pages_kb)*1024)/8192 as total_stolen_pages, type
from sys.dm_os_memory_clerks
group by typeorder by total_stolen_pages desc
and
select sum(pages_allocated_count * page_size_in_bytes)/1024,type from sys.dm_os_memory_objects
group by type
If you can post the output of above two queries with dbcc memorystaus output on some shared drive and share location with us here. I would try to find out what is leaking memory.
You can very well apply SQL Server 2008 r2 SP3 and see if this issue subsides but I am not sure whether this is fixed or actually it is a bug.
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Wiki Article
MVP -
hi
i need query to find out for one perticular row from parent table ,,which references how many rows in how many child tables , and child to child tables. in herirachy fashion.
if anybody know please help meI guess it would be difficult to come up with a generic script to get answer that can help in all situations...you have to see the table definitions in your schema and try...like in case of emp and dept table,
select * from dept where deptno in
(select deptno,count(*) from emp group by deptno having count(*)>1)
(this gives rows from dept table where , for corresponding deptno there are more than one rows in emp table).
Thanks
Nirav -
How to do query Optimization ,plz share any documents with real examples
Hi All,
could any one please provide me some informations, how can i do query optimization in oracle using Third party tool sql developer .
i am working oracle 10g version,please share with me if any documents or ppt like that.
Thanks
Krupa879534 wrote:
Hi All,
could any one please provide me some informations, how can i do query optimization in oracle using Third party tool sql developer .SQL Developer is Oracle's development tool, not a third party tool.
Questions about using SQL Developer should go in the SQL Developer forum:
SQL Developer
I'll move the question there for you. -
Need Query - join in same table
I need query for following criteria,
Table : test
No Order
1 a
1 b
1 c
2 a
2 b
2 d
3 e
3 f
3 g
3 h
1 f
2 f
Consider the above table,
1) I will give input order as a,b: It should return No 1,2
No Order
1 a
1 b
1 c
2 a
2 b
2 d
3 e
3 f
3 g
3 h
1 f
2 f
2) I will give input order as f,g,h: It should return No 3
No Order
1 a
1 b
1 c
2 a
2 b
2 d
3 e
3 f
3 g
3 h
1 f
2 f
Please give me the query which will give above result.
ThanksI am not sure I understand you, but it may be this
with test as (
select 1 N, 'a' Ord from dual union all
select 1,'b' from dual union all
select 1,'c' from dual union all
select 2,'a' from dual union all
select 2,'b' from dual union all
select 2,'d' from dual union all
select 3,'e' from dual union all
select 3,'f' from dual union all
select 3,'g' from dual union all
select 3,'h' from dual union all
select 1,'f' from dual union all
select 2,'f' from dual )
select N from test tp where Ord = 'a'
intersect
select N from test tp where Ord = 'b';
with test as (
select 1 N, 'a' Ord from dual union all
select 1,'b' from dual union all
select 1,'c' from dual union all
select 2,'a' from dual union all
select 2,'b' from dual union all
select 2,'d' from dual union all
select 3,'e' from dual union all
select 3,'f' from dual union all
select 3,'g' from dual union all
select 3,'h' from dual union all
select 1,'f' from dual union all
select 2,'f' from dual )
select N from test tp where Ord = 'f'
intersect
select N from test tp where Ord = 'g'
intersect
select N from test tp where Ord = 'h';
Maybe you are looking for
-
Like an idiot I changed the location of my iTunes Media File in the Advanced section of my Preferences - now half my songs won't play as they can't be found....I know they are there as I played these songs yesterday.....help !!!.... .....what folder
-
Z97-G45 HDMI port doesn't work
I have Z97-G45 the HDMI doesn't work what's the problem? should i install driver for it?
-
Has anyone successfully synced their Palm PDA (I have a TX) with their Mac using WiFi? I get them to recognize each other, but when I actually do the sync, it just sits there for a couple minutes and then tells me it couldn't make a connection. I don
-
After update trigger firing on after insert
Hi All, I am using oracle database version 8i. I have one database trigger create or replace trigger mna_post_update after update on mobile_number_actions for each row when (new.mna_status = 'P' and new.mna_type in ('I','C','R','D','M','T','A','N','O
-
Accurate time between digital on/off
Hi All I had posted this before in software board but i think this board is more appropriate. I am operating a valve which uses a digital signal (1 or 0) to switch on and off. I need to vary the time it remains open from 5 ms to 100 ms. I was using '