Alternate query to Remove minus operator
Hi All,
The query below does following
First Query Find all the GL accounts within date range and second query find all GL Elimination Accounts from GL Elimination setup.
By Using minus i will find out which accounts are not setup in GL Elimination Setup Form. I want your help in finding desired output not using minus?
What are the other alternatives?
SELECT
/*+ ORDERED
USE_NL(jel jeh jeb cat src)
INDEX(jel GL_JE_LINES_N1)
INDEX(jeh GL_JE_HEADERS_U1)
INDEX(jeb GL_JE_BATCHES_U1)
INDEX(cat GL_JE_CATEGORIES_TL_U1)
INDEX(src GL_JE_SOURCES_TL_U1) */
CC.SEGMENT1
||'.'
||CC.segment2
||'.'
||CC.segment3
||'.'
||cc.segment4
||'.'
|| cc.segment5
||'.'
|| cc.segment6 Account,
decode(sysdate,sysdate,sysdate,jel.effective_date) trx_date
FROM gl_code_combinations cc,
gl_je_lines jel,
gl_je_headers jeh,
gl_je_batches jeb,
gl_je_categories cat,
gl_je_sources src
WHERE cc.CHART_OF_ACCOUNTS_ID = 50308
AND cc.segment2 IN ('111710','201910')
AND jel.code_combination_id = cc.code_combination_id
AND jel.status
|| '' = 'P'
AND (jel.accounted_cr != 0
OR jel.accounted_dr != 0)
AND jeh.je_header_id = jel.je_header_id
AND jeh.actual_flag = 'A'
AND jeh.currency_code != 'STAT'
AND jeb.je_batch_id = jeh.je_batch_id
AND jeb.average_journal_flag = 'N'
AND src.je_source_name = jeh.je_source
AND cat.je_category_name = jeh.je_category
and jel.effective_date between to_date('01-JAN-2011','DD-MON-RRRR') and to_date('31-MAY-2011','DD-MON-RRRR')
MINUS
SELECT (source_segment1
||'.'
||source_segment2
||'.'
||source_segment3
||'.'
||source_segment4
||'.'
||source_segment5
||'.'
||source_segment6) def_acnt,
sysdate
FROM GL_ELIM_ACCOUNTS_MAP
Hi
For performance it is better if you use Not exists as given below
SELECT
/*+ ORDERED
USE_NL(jel jeh jeb cat src)
INDEX(jel GL_JE_LINES_N1)
INDEX(jeh GL_JE_HEADERS_U1)
INDEX(jeb GL_JE_BATCHES_U1)
INDEX(cat GL_JE_CATEGORIES_TL_U1)
INDEX(src GL_JE_SOURCES_TL_U1) */
CC.SEGMENT1
||'.'
||CC.segment2
||'.'
||CC.segment3
||'.'
||cc.segment4
||'.'
|| cc.segment5
||'.'
|| cc.segment6 Account,
decode(sysdate,sysdate,sysdate,jel.effective_date) trx_date
FROM gl_code_combinations cc,
gl_je_lines jel,
gl_je_headers jeh,
gl_je_batches jeb,
gl_je_categories cat,
gl_je_sources src
WHERE cc.CHART_OF_ACCOUNTS_ID = 50308
AND cc.segment2 IN ('111710','201910')
AND jel.code_combination_id = cc.code_combination_id
AND jel.status
|| '' = 'P'
AND (jel.accounted_cr != 0
OR jel.accounted_dr != 0)
AND jeh.je_header_id = jel.je_header_id
AND jeh.actual_flag = 'A'
AND jeh.currency_code != 'STAT'
AND jeb.je_batch_id = jeh.je_batch_id
AND jeb.average_journal_flag = 'N'
AND src.je_source_name = jeh.je_source
AND cat.je_category_name = jeh.je_category
and jel.effective_date between to_date('01-JAN-2011','DD-MON-RRRR') and to_date('31-MAY-2011','DD-MON-RRRR') AND
NOT EXISTS (
SELECT 'x'
FROM GL_ELIM_ACCOUNTS_MAP
WHERE CC.SEGMENT1
||'.'
||CC.segment2
||'.'
||CC.segment3
||'.'
||cc.segment4
||'.'
|| cc.segment5
||'.'
|| cc.segment6 Account != source_segment1
||'.'
||source_segment2
||'.'
||source_segment3
||'.'
||source_segment4
||'.'
||source_segment5
||'.'
||source_segment6 )
Similar Messages
-
Minus operator versus 'not exists' for faster SQL query
Hi everybody,
Does anyone know if rewriting a query to use the MINUS operator instead of using NOT EXISTS in the query is faster, giving all else is the same?
Thanks very much!
Bill Loggins
801-971-6837
[email protected]It really depends on a bunch of factors.
A MINUS will do a full table scan on both tables unless there is some criteria in the where clause of both queries that allows an index range scan. A MINUS also requires that both queries have the same number of columns, and that each column has the same data type as the corresponding column in the other query (or one convertible to the same type). A MINUS will return all rows from the first query where there is not an exact match column for column with the second query. A MINUS also requires an implicit sort of both queries
NOT EXISTS will read the sub-query once for each row in the outer query. If the correlation field (you are running a correlated sub-query?) is an indexed field, then only an index scan is done.
The choice of which construct to use depends on the type of data you want to return, and also the relative sizes of the two tables/queries. If the outer table is small relative to the inner one, and the inner table is indexed (preferrable a unique index but not required) on the correlation field, then NOT EXISTS will probably be faster since the index lookup will be pretty fast, and only executed a relatively few times. If both tables a roughly the same size, then MINUS might be faster, particularly if you can live with only seeing fields that you are comparing on.
For example, if you have two tables
EMPLOYEE
EMPID NUMBER
NAME VARCHAR2(45)
JOB VARCHAR2(45)
HIRE_DATE DATE
and
RETIREE
EMPID NUMBER
NAME VARCHAR2(45)
RET_DATE DATEIf you wanted to see if you had retirees that were not in the employee table, then you could use either MINUS or NOT EXISTS (or even NOT IN, but you didn't ask). However you could possibly get different results.
SELECT empid,name
FROM retirees
MINUS
SELECT empid,name
FROM employeeswould show retirees not in the emp table, but it would also show a retiree who had changed their name while retired. A safer version of the above using MINUS would be
SELECT empid,name
FROM retirees
WHERE empid IN (SELECT empid
FROM retirees
MINUS
SELECT empid
FROM employees)A full scan of retirees, a full scan of employees (Assuming indexes on both, then maybe an index fast full scan) and two sorts for the minus, at best an index probe then table access by rowid on retirees, possibly a full scan of retirees for the outer query.
Assuming that employees is indexd on empid then
SELECT empid,name
FROM retirees
WHERE NOT EXISTS (SELECT 1
FROM employees
WHERE retirees.empid = employees.empid)requires a full scan of retirees and an index access into employees index for each row.
As with most things SQL, the only real way to tell is to benchmark.
HTH
John -
Alternate query to LIKE operator
I have table with contains 65 lakes records, I need to delete the records which does not contains space in column values
Ex : table
Code test_num
NL 123 AP
NL 567ZP
NL 427 SL
NL 456IP
I had return the query like these Delete table A where test_num is not like ‘% %”;
But the problem is the query is getting hang. Because of I am using like operator
Please let me know is there is any alternate query to write
If there any PLSQL to write fetch the query 1laksh records and then delete the records
Deleted rows count is 20Lakuser13711017 wrote:
I had return the query like these Delete table A where test_num is not like ‘% %”;
But the problem is the query is getting hang. Because of I am using like operator
What makes you think so?
It could "hang" (you probably mean "take a long time") due to many other reasons:
- Your system is busy with other stuff and your process gets only partial system resources;
- There is a delete (row) trigger on that table that takes a lot of time;
- The table has many indexes, whose maintenance takes a lot of time;
I doubt it is "because of you using like operator"... -
Minus operator abnormal behavior question
Oracle 10gR2/Oracle 11g on Windows 2003 R2 32-bit
There is a very weird query with minus, it is basically:
select id from table1 where xxxx --> query 1
minus
select id from table1 where xxxx --> query 2the queries are against the same table, only difference is the where clause. There are 3rd party implemented type and index being used in the where clause in both queries.
query 1 returns 100 records (i.e. all the records in table1), query 2 returns 0 record.
but with the minus operator, it returns 1 record.
If I modify query 2, remove the 3rd party type/index, use another filter that will return 0 record too, then the minus query returns 100 records correctly.
If I modify the whole query to use not in/not exist instead of minus, then query returns 100 records correctly.
Question: is it possible the 3rd party type/index can cause the minus operator to behave this way?
Edited by: modeler on Nov 18, 2009 3:15 PM
Edited by: modeler on Nov 18, 2009 3:16 PMIs there any way you can put together a representative test case that we can test here?
-
Hi all ,
I have a requirement to use MINUS operator in a column of a report . Since it is available for two separate criteria , Could someone suggest how to perform the same in OBIEE 11g for a column.
the conditions to be implemented in a column are
select count(*) from (
select distinct trx.shipment_header_id
from
F_ERP_PO_RECEIPTS_TRX trx
where trx.transaction_type = 'RECEIVE'
MINUS
select distinct rec.shipment_header_id
from
where trx.transaction_type = 'DELIVER').
How can i perform these conditions for a column of a report .
Reg,
Niv DHi Niv D,
I guess this can be done as we have union, union all and minus available.
once you select the required subject area say SA for the below query,
select distinct trx.shipment_header_id
from
F_ERP_PO_RECEIPTS_TRX trx
where trx.transaction_type = 'RECEIVE'
on the right side of the criteria you can see a + symbol with venn diagram. once you click on it, it gives you an option to select the next SA for
select distinct rec.shipment_header_id
from
where trx.transaction_type = 'DELIVER').
once you selected that, you can see the criteria changes accordingly.
there you change to union or minus.
once you have the conditions for both, make the layout as pivot and apply count on the column. you are there with the result,
I tried earlier with union but not with minus. but this should work.
Regards,
KN
ebs2obiee.wordpress.com -
Hi
i use this minus operator to find the non matching row of the second query.
after looking at the reasult of this query , i searched the one result in the second query alone i could see the data.
it's worng The MINUS query returns all rows in the first query that are not returned in the second query.
in my case it's returning the rows which returned by the second query.
(select distinct lower(trim(to_char(sso))),lower(trim(to_char(region))),to_date(expiration_date,'DD-MM-YY') from ca_ourc_view
where rownum <1001
minus
(select distinct lower(trim(to_char(sso))),lower(trim(to_char(region))),to_date(expiration_date,'DD-MM-YY') from ourc_members_v1@gesprd
where rownum <1001
)thanks
Rajin my case it's returning the rows which returned by the second query.can't happen like this
for example
SQL> select * from scott.emp where empno=7369
2 minus
3 select * from scott.emp where empno=7499;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20 -
How to use LIKE , IN, NULL combined to remove OR operator.
I have a query to get result but we can not use OR operator here. I am trying to find if I can use IN operator somehow to get rid of OR.
Query - Select * from table where col1 like ('%ABC%') or col1 is null;
I am trying to find some query like - Select * from table where col1 IN ('%ABC%', null);
I tried even following but didnt work - Select * from table where col1 IN ('ABC', '');
I just want to remove OR operator from query. Thanks in advance.user11032875 wrote:
I have a query to get result but we can not use OR operator here. I am trying to find if I can use IN operator somehow to get rid of OR.
Query - Select * from table where col1 like ('%ABC%') or col1 is null;
I am trying to find some query like - Select * from table where col1 IN ('%ABC%', null);
I tried even following but didnt work - Select * from table where col1 IN ('ABC', '');
I just want to remove OR operator from query. Thanks in advance.Select * from table where col1 like ('%ABC%');
union
Select * from table where col1 is null; -
MINUS operation with remote table
Hi all,
Please help me with this problem.
I have two tables with 20 columns each, one table resides on one database and the other table is accesed through a db link. Both tables contains +800,000 records.
I need to know the record differences between these two tables - this is a periodical process, not for once- , I am using a MINUS operation with full scan, the problem is that my query is taking long time to finish : +20 min. Also i tried witn COLUMN IN() instead MINUS but my query performance is worst.
Do you know another way to get the record differences with a better performance?
Thanks in advance
Edited by: Osymad on Jun 18, 2012 5:12 PMOsymad wrote:
Hi all,
Please help me with this problem.
I have two tables with 20 columns each, one table resides on one database and the other table is accesed through a db link. Both tables contains +800,000 records.
I need to know the record differences between these two tables - this is a periodical process, not for once- , I am using a MINUS operation with full scan, the problem is that my query is taking long time to finish : +20 min. Also i tried witn COLUMN IN() instead MINUS but my query performance is worst.
Do you know another way to get the record differences with a better performance?
Thanks in advance
Edited by: Osymad on Jun 18, 2012 5:12 PMhttp://www.oracle.com/technetwork/issue-archive/2005/05-jan/o15asktom-084959.html
Search for "Comparing the Contents of Two Tables"
Cheers, -
MINUS operator fetches invalid record count
Hi,
One of the application team complained that oracle MINUS operator fetches an invalid record count after data load.
Here are the details of the data load:
They are using source as PROD and target as UAT.
They are replicating the data on UAT environment in schema A from fetching the data in PROD from the same schema.
After load when we query the count of records in UAT it shows more records in target, that is in UAT, than PROD.
When they use MINUS operator to fetch the extra records in UAT, it shows no rows selected.
SQL> select 'A' count(1) from A.UAT union all select 'A' count(1) from A.PROD@BISLSPD1;
A COUNT(1)
A.UAT 19105022
A.PROD 19104995
SQL> select distinct count(*) from (select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1);
COUNT(*)
0
SQL> select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1
no rows selected
Please note that both are partitioned tables and they are using Informatica Data Replication 9.5 tool to populate the data from source to target.
Not sure if this could be a bug or an issue.
PROD DB Version: 10.2.0.5
UAT DB Version: 10.2.0.5
Both are in Linux 2.6
Please throw some light on this.974065 wrote:
SQL> select 'A' count(1) from A.UAT union all select 'A' count(1) from A.PROD@BISLSPD1;
A COUNT(1)
A.UAT 19105022
A.PROD 19104995
SQL> select distinct count(*) from (select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1);
COUNT(*)
0
SQL> select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.UAT minus select distinct DW_DISCOUNT_KEY, DW_DISCOUNT_MODIFIER_KEY from A.PROD@BISLSPD1
no rows selected
Given that you've go "distinct" in your query, you're eliminating duplicates from each table (and MINUS implicitly means distinct anyway). Check for duplicates (of dw_discount_key, dw_discount_modifier_key) in both tables.
If the combination is actually unique, I would check that you actually had the raw results the right way round - MINUS is not symmetrical, and for a complete picture you need to look at (select from uat minus select from prod) union all (select from prod minus select from uat)
Regards
Jonathan Lewis -
I am very new to oracle and am working with the minus operator to run a query. I could use some help!
Here is the query I am working on:
select suppliername, partname
from quote
where partname = 'hammer'
minus
select suppliername, partname
from quote
where partname = 'hammer';
HOW DO I GET THE QUERY TO DISPLAY ONLY THE ROWS OF SUPPLIERNAMES THAT SUPPLY ONLY HAMMERS?
I WOULD GREATLY APPRECIATE SOME CLARIFICATION.HOW DO I GET THE QUERY TO DISPLAY ONLY THE ROWS OF SUPPLIERNAMES THAT SUPPLY ONLY HAMMERS?It may, for some data related reason, give you the result you were expecting, but this query does not answer that question because you have included partname in the MINUS.
E.g.
WITH quote AS
(SELECT 'BOB' suppliername, 'HAMMER' partname FROM DUAL UNION ALL
SELECT 'BOB' suppliername, 'SPANNER' partname FROM DUAL UNION ALL
SELECT 'TIM' suppliername, 'HAMMER' partname FROM DUAL UNION ALL
SELECT 'JACK' suppliername, 'HAMMER' partname FROM DUAL)
SELECT suppliername, partname
FROM quote
MINUS
SELECT suppliername, partname
FROM quote
WHERE partname != 'HAMMER';
SUPPLIERNAME PARTNAME
BOB HAMMER
JACK HAMMER
TIM HAMMER Clearly this is wrong because Bob supplies spanners (aka wrench).
However:
WITH quote AS
(SELECT 'BOB' suppliername, 'HAMMER' partname FROM DUAL UNION ALL
SELECT 'BOB' suppliername, 'SPANNER' partname FROM DUAL UNION ALL
SELECT 'TIM' suppliername, 'HAMMER' partname FROM DUAL UNION ALL
SELECT 'JACK' suppliername, 'HAMMER' partname FROM DUAL)
SELECT suppliername
FROM quote
MINUS
SELECT suppliername
FROM quote
WHERE partname != 'HAMMER';
SUPPLIERNAME
JACK
TIM Amongst the many alternatives - NOT EXISTS:
WITH quote AS
(SELECT 'BOB' suppliername, 'HAMMER' partname FROM DUAL UNION ALL
SELECT 'BOB' suppliername, 'SPANNER' partname FROM DUAL UNION ALL
SELECT 'TIM' suppliername, 'HAMMER' partname FROM DUAL UNION ALL
SELECT 'JACK' suppliername, 'HAMMER' partname FROM DUAL)
SELECT *
FROM quote q1
WHERE NOT EXISTS (SELECT 1
FROM quote q2
WHERE q2.suppliername = q1.suppliername
AND partname != 'HAMMER');
SUPPLIERNAME PARTNAME
JACK HAMMER
TIM HAMMER -
Instead of Minus operation any other ?
Hi,
Master Table : book_master
Master_Pk_No Book_Name Version_no I_User Initial_id
10 Book1 0 XXX 10
20 Book1 1 XXX 10
30 Book1 2 XXX 10
# Initial id will be same as Master_Pk_No first number
# I have to take the latest version ( 2 ) and compare with the older version if any records
are availble in older version i have to fetch that and append that with the
Child Table : source
C_PK_NO SEQ_SOURCE UNIT_SEQ O_User
10 1 1 XXX
10 2 1 abc
10 3 2 abc
10 4 1 ggg
10 5 2 ggg
10 6 3 abc
10 7 4 abc
20 1 1 XXX
20 2 1 abc
20 3 2 abc
20 4 1 ggg
20 5 2 ggg
20 6 1 zzz
30 1 1 XXX
30 2 1 abc
30 3 2 abc
30 4 1 ggg
30 5 2 ggg
30 6 2 XXX
SELECT seq_source, o_user, unit_seq
FROM SOURCE
WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
WHERE book_name = 'Book1'
AND version_no = 0 )
MINUS
SELECT seq_source, o_user, unit_seq
FROM SOURCE
WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
WHERE book_name = 'Book1'
AND version_no = 2) ;
If i execute this query i will get the below result .
C_PK_NO SEQ_SOURCE UNIT_SEQ O_User
10 6 3 abc
10 7 4 abc
SELECT seq_source, o_user, unit_seq
FROM SOURCE
WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
WHERE book_name = 'Book1'
AND version_no = 1 )
MINUS
SELECT seq_source, o_user, unit_seq
FROM SOURCE
WHERE c_pk_no IN ( SELECT master_pk_no FROM AER
WHERE book_name = 'Book1'
AND version_no = 2) ;
C_PK_NO SEQ_SOURCE UNIT_SEQ O_User
20 6 1 zzz
is it possible to achieve this without minus operation ?
Regards,
KBG.And here is the test:
SQL> WITH BOOK_MASTER AS(
2 SELECT 10 master_pk_no,'Book1' book_name,0 version_no,'XXX' i_user,10 Initial_id from dual union all
3 SELECT 20,'Book1',1,'XXX',10 from dual union all
4 SELECT 30,'Book1',2,'XXX',10 from dual
5 ),
6 SOURCE AS (
7 SELECT 10 c_pk_no,1 seq_source,1 unit_seq,'XXX' o_user from dual union all
8 SELECT 10,2,1,'abc' from dual union all
9 SELECT 10,3,2,'abc' from dual union all
10 SELECT 10,4,1,'ggg' from dual union all
11 SELECT 10,5,2,'ggg' from dual union all
12 SELECT 10,6,3,'abc' from dual union all
13 SELECT 10,7,4,'abc' from dual union all
14 SELECT 20,1,1,'XXX' from dual union all
15 SELECT 20,2,1,'abc' from dual union all
16 SELECT 20,3,2,'abc' from dual union all
17 SELECT 20,4,1,'ggg' from dual union all
18 SELECT 20,5,2,'ggg' from dual union all
19 SELECT 20,6,1,'zzz' from dual union all
20 SELECT 30,1,1,'XXX' from dual union all
21 SELECT 30,2,1,'abc' from dual union all
22 SELECT 30,3,2,'abc' from dual union all
23 SELECT 30,4,1,'ggg' from dual union all
24 SELECT 30,5,2,'ggg' from dual union all
25 SELECT 30,6,2,'XXX' from dual
26 )
27 SELECT s.seq_source,
28 s.o_user,
29 s.unit_seq
30 FROM SOURCE s,
31 BOOK_MASTER a
32 WHERE s.c_pk_no = a.master_pk_no
33 AND a.book_name = 'Book1'
34 AND a.version_no IN (0,2)
35 GROUP BY s.seq_source,
36 s.o_user,
37 s.unit_seq
38 HAVING MAX(a.version_no) = 0
39 /
SEQ_SOURCE O_U UNIT_SEQ
6 abc 3
7 abc 4
SQL> WITH BOOK_MASTER AS(
2 SELECT 10 master_pk_no,'Book1' book_name,0 version_no,'XXX' i_user,10 Initial_id from dual union all
3 SELECT 20,'Book1',1,'XXX',10 from dual union all
4 SELECT 30,'Book1',2,'XXX',10 from dual
5 ),
6 SOURCE AS (
7 SELECT 10 c_pk_no,1 seq_source,1 unit_seq,'XXX' o_user from dual union all
8 SELECT 10,2,1,'abc' from dual union all
9 SELECT 10,3,2,'abc' from dual union all
10 SELECT 10,4,1,'ggg' from dual union all
11 SELECT 10,5,2,'ggg' from dual union all
12 SELECT 10,6,3,'abc' from dual union all
13 SELECT 10,7,4,'abc' from dual union all
14 SELECT 20,1,1,'XXX' from dual union all
15 SELECT 20,2,1,'abc' from dual union all
16 SELECT 20,3,2,'abc' from dual union all
17 SELECT 20,4,1,'ggg' from dual union all
18 SELECT 20,5,2,'ggg' from dual union all
19 SELECT 20,6,1,'zzz' from dual union all
20 SELECT 30,1,1,'XXX' from dual union all
21 SELECT 30,2,1,'abc' from dual union all
22 SELECT 30,3,2,'abc' from dual union all
23 SELECT 30,4,1,'ggg' from dual union all
24 SELECT 30,5,2,'ggg' from dual union all
25 SELECT 30,6,2,'XXX' from dual
26 )
27 SELECT s.seq_source,
28 s.o_user,
29 s.unit_seq
30 FROM SOURCE s,
31 BOOK_MASTER a
32 WHERE s.c_pk_no = a.master_pk_no
33 AND a.book_name = 'Book1'
34 AND a.version_no IN (1,2)
35 GROUP BY s.seq_source,
36 s.o_user,
37 s.unit_seq
38 HAVING MAX(a.version_no) = 1
39 /
SEQ_SOURCE O_U UNIT_SEQ
6 zzz 1
SQL> SY. -
Hi All,
I have created a report utilizing the minus operation as follows:
Person_Wid (Filtered by a set of criteria selected by users via prompts)
minus
Person_wid (Filtered by another set of criteria selected by users via prompts)
I get the correct person_wids.
However I need to calculate count of the person_wid obtained in the result. Can someone tell me how I can achieve this.
ThanksHi David,
Thanks for ur suggestion. However the query I am trying to execute is
Person_Wid (Filtered by a set of criteria selected by users via prompts) ----->A
minus
Person_wid (Filtered by another set of criteria selected by users via prompts)--------->B
So when I implement what you suggested I get the count of only 'A'. It does not give me the row count of (A-B). Is there something I need to tweak?
Thanks,
Nikita -
Hi everyone,
I am trying to find a way to do minus operations on table. I know this is possible in SQL, but I have yet to find out how to do it in ABAP. Can anyone help?
What I need to do is the following.
Let table A = (A,B,C,D,E) and table B = (B,C,E), then A minus B would return (A,D). Is there a function in ABAP for this?
Thank you very much in advance.
Philip R. Jarnhushello,
u can use subqueries:
http://help.sap.com/saphelp_NW04/helpdata/en/dc/dc7614099b11d295320000e8353423/content.htm
it is easy, but wrong way to solve your problem. This select will make a lot of calls to your DB.
better way:
1) two selects from table 1 and table 2 into two different internal tables.
define two internal tables in your code. One table should have standard tables type and another hashed tables type with unique.
2) subtract the result:
loop at it_1 into ls_1.
lv_tabix = sy-tabix.
read table lt_1 transporting no fields with table key column_name = ls_1-column_name.
check sy-subrc eq 0.
delete it_1 index lv_tabix.
endloop.
this solution will speed up your application. -
Use of double Minus operator....
Hi ,
I have a situation where i need to use the minus operator in such a way that:
<sql_statement_A>
Minus
<sql_statement_B>
Minus
<sql_statement_C>
The resulting row set will return rows from sql_statement_A minus rows from sql_statement_B or sql_statement_A minus rows from sql_statement_C... Is the above sql pattern is correct....or , do i need to write two views
<sql_statement_A>
Minus
<sql_statement_B>
and
<sql_statement_A>
Minus
<sql_statement_C>
and one third making Union of the two above...????
many thanks,
SimonIf in doubt, use parentheses to make them run the way you want.
So..
(<sql_statement_A>
minus
<sql_statement_B>)
minus
<sql_statement_C>
Just like OR conditions in the where clause, grouping with parentheses will greatly help those who come later to maintain it. And this looks simpler and more efficient than using two minus operations and combining the result. -
Error while doing MINUS operation
Hi ,
i am using MINUS operation.I am getting the error
*State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 59019] All of the input streams to the Union operator should have an identical number of columns and union compatible data types. (HY000)*
I used same data type and i checked with rpd also its working fine.Where is the problem .Can any one help me out??
Thanks,
Saichand.Vhi,
Thanks for u quick response
Those are from two Different tables.in Fx i didn't used any operations.Just pulled certain columns.one column is prompted in both the reports.
Maybe you are looking for
-
I hope I explain this right. I don't have much experience with anchored objects in InDesign and I got catalog files for my job and I can't figure this out. On the page there are a bunch of boxes anchored to the columns(first image), within that ancho
-
Listing a subdir's contents?
Hi I'm wondering how to change the following code so that I get a listing of files in a folder called 'tester' that resides in the documentsDirectory? var directory:File = File.documentsDirectory; directory.getDirectoryListingAsync(); directory.addEv
-
Calling an overloading function
Hi all, How can I call an overloading function from outside the package without using the package name, For example : CREATE PACKAGE PACK FUNCTION X(P_INTERVAL IN VARCHAR2, P_INTERVAL_VAL IN NUMBER, P_DATE_STR IN VARCHAR2) RETURN TIMESTAMP; FUNCTION
-
Numbers running very slow on Yosemite, new 3.1 GHz Intel Core i7 Fusion Drive
When I initially start working in Numbers, it runs very smoothly, but after a minute or two, it drags like crazy. Even just to highlight a cell takes 5 seconds or more. It's really terrible. I've done permissions and disk repair. Any advice as to
-
While creating a propagation session on Workshop 9.2 that merges the assets of my source and production environments i get this error that prevents me to selectively choose the nodes to propagate: <pre> java.lang.StringIndexOutOfBoundsException: Stri