Join two tables to query the difference of both

Hi,
I think my problem is not the hardest, but I don't find a solution.
- i have two tables: t_old, t_new
- both have the same attribute (item_nr)
- t_new exists of some rows from t_old and some new rows
I want to query only the new rows from t_new, that aren't in the table t_old.
Who can help me please..???
Regards,
Steffen

wrong forum, sorry, but i got it in another forum:
select * from t_new n
where not exists
(select 1 from t_old o
where n.item_nbr = o.item_nbr)
(THX to Keith Jamieson)
or
select * from t_new
minus
select * from t_old
(THX to Boneist)

Similar Messages

  • Compare two tables and log the difference

    Hi,
    I want to compare two tables and log the difference in new table with the fields as (old value,new value, column name). The column name should be the changes value column

    Can you show an example?
    SELECT Foo.*, Bar.*
       FROM Foo
            FULL OUTER JOIN
            Bar
            ON Foo.c1 = Bar.c1
               AND Foo.c2 = Bar.c2
               AND Foo.cn = Bar.cn
     WHERE Foo.key IS NULL 
        OR Bar.key IS NULL; 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Joining two tables, sql query

    This is a newbie question! I would like to join two tables. Table_1 contains xml stylesheets:
    id stylesheet doc
    1 <xml stylesheet doc A>
    2 <xml stylesheet doc B>
    And Table_2 contains the XML documents that the stylesheets will transform:
    id XML doc
    1 <XML document 1>
    1 <XML document 2>
    1 <XML document 3>
    2 <XML document 4>
    2 <XML document 5>
    I would like <xml stylesheet doc A> to transform only XML doc that have an id of 1, so I tried this sql statement:
    select a.stylesheet_doc ,b.xml_doc from Table_1 a, Table_2 b where a.id=b.id and a.id=1;
    This statement returns the rows I want (stylesheet doc with id equals 1, and xml_doc with id equals 1), but it pairs each xml document with a style sheet.
    stylesheet doc A <XML document 1>
    stylesheet doc A <XML document 2>
    stylesheet doc A <XML document 3>
    My question is, is there a way to have a result that looks like this?
    stylesheet doc A
    <XML document 1>
    <XML document 2>
    <XML document 3>
    That is, is there a way in sql to get rid of duplicate stylesheet doc A?
    I have tried group by and rollup and xmlagg.
    Thank you very, very much for your help.
    Jim

    Hi, Jim,
    Welcome to the forum!
    You just want to display the XML, not actually transform it, right?
    GROUP BY ROLLUP should work, but I find it easier with GROUP BY GROUPING SETS. Here's an example from tables in the scott schema:
    SELECT       CASE
              WHEN  GROUPING (ename) = 1
              THEN  d.dname
           END          AS dname
    ,       e.ename
    FROM       scott.dept     d
    JOIN       scott.emp     e  ON     d.deptno     = e.deptno
    GROUP BY  GROUPING SETS ( (d.dname, e.ename)
                   , (d.dname)
    ORDER BY  d.dname
    ,       ename          NULLS FIRST
    ;Output:
    DNAME          ENAME
    ACCOUNTING
                   CLARK
                   KING
                   MILLER
    RESEARCH
                   ADAMS
                   FORD
                   JONES
                   SCOTT
                   SMITH
    SALES
                   ALLEN
                   BLAKE
                   JAMES
                   MARTIN
                   TURNER
                   WARDYou may have noticed that this site noramlly compresses whitespace.
    Whenever you post formatted text (such as query results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Join two tables which stored in difference database

    Hi, i have a problem how to join two tables which are stored in difference databases. I'm using MS access and need to use Jsp to solve it. is anyone have idea to solve it. thxx

    Hi,
    I think you cannot join the tables which are in two diff databases. You have to connect to each database ,get the result and manipulate in your program. Use a bean.
    cheers,
    Narayana

  • Outer join two tables with query search record attached to both tables

    When I create a query with two tables that have query search records attached with outer join, PS seems to do a natural join (cartesian). We are on PT8.48.
    Is there a workaround for this issue. I do not want to remove query search record on either of the tables.
    I am trying to create an Emergency contact report. I am using two tables PS_EMPLOYEES and PS_EMERGENCY_CNTCT. Here is the sql PeopleSoft query generated when I did Left outer Join.
    Query SQL:
    SELECT A.EMPLID, A.NAME, A.ADDRESS1, A.CITY, B.PRIMARY_CONTACT, B.ADDRESS1, B.CITY, B.STATE, B.POSTAL, B.RELATIONSHIP, A.DEPTID, A.JOBCODE, A.COMPANY, A.EMPL_TYPE
    FROM (PS_EMPLOYEES A LEFT OUTER JOIN PS_EMERGENCY_CNTCT B ON A.EMPLID = B.EMPLID ), PS_EMPLMT_SRCH_QRY A1, PS_PERS_SRCH_QRY B1
    WHERE A.EMPLID = A1.EMPLID
    AND A.EMPL_RCD = A1.EMPL_RCD
    AND A1.OPRID = 'SREESR'
    AND (B.EMPLID = B1.EMPLID OR B.EMPLID IS NULL )
    AND B1.OPRID = 'PS'
    Appreciate any help.

    I think there are fixes for this issue in later tools releases (Report ID 1544345000). I'm not sure about 8.48, but you might try the workaround documented in
    E-QR: Left Outer Joins with Security Records are returning unexpected results [ID 651252.1]
    on Oracle Support.
    Regards,
    Bob

  • How to join two tables and get the supply delivery date next to order?

    So there are two tables. One has customer's order no, ordered date, order quantity, available quantity and code of article-
    The other table comes form supply side where we have supply order no, article number, ordered qty, and delivery date.
    We keep stock so this can not be MOT (made to order) system.
    What i need is correct date of arrival to appear next to cusotmers spoecirfic order. The older cusotmers order get's the parts first, second oldest order is next in line etc.
    here is any example
    customer's order
    ref order
    art. code
    ordered qty
    available qty
    order date
    1809202491
    700497
    60
    0
    3.7.2014
    1809200528
    700497
    13
    0
    20.6.2014
    1809198640
    700497
    7
    0
    9.6.2014
    supply order
    supply order
    art. code
    qty orderd
    date of arrival
    4501243378
    700497
    50
    4.8.2014
    4501263437
    700497
    20
    6.10.2014
    There is actually a 3rd "table" and that sort of connects the two and that is stock on hand per art. code.
    The main issue is that stock is assigned to purchase orders only when it actually arrives in the warehouse.
    A human can easilly connect the dates of when the stock will arrive and quantities with correct customer's order. In this case the firts order will get 50 pcs in August while 10 pcs will remain on backorders. The missing 10 pcs Will arrive in October. The second order will get 10 pcs in october and 3 will remain on backorders with no delivery date. While the third customer orders does not have a delivery date.
    So how to make the SAP do this calculations and display the arrival date next to date of customer's order?

    I checked the instructions as i do not have access to this part. It seem this is a query. We had issues with queries in the past as not all codes from orders would appear in them. They never found the reason why that is happening.
    However, I think the main issue is that the information here is not connected and is separately provided for supply and for sales. So i doubt it can be connected in this query.
    edit: as you can see the only connection is stock on hand.
    and total number of various items we have is close to 100.000 of various article codes.

  • Optimizing the Query  joining two tables multiple times

    Hi all,
    I need to formulate a query where I want to get data from two tables.Here are the table structures and sample data.
    Table1
    id firstname lastname accountnumber
    1 Sridh Peter SP456
    2 Gane San SS667
    3 Sway patel PP345
    Table 2
    id attributename attributevalue
    1 Manager Mike
    1 Lawyer Schwa
    1 Server maneka
    1 location langur
    1 System Novel
    2 Manager kane
    2 lawyer endun
    2 location colrado
    3 server queen
    3 system elanda
    The requirement is I need to generate a report like th follwoing
    Accountnumber firstname lastname manager lawyer System Server location
    SP456 Sridh Peter Mike schwa Novel maneka langur
    SS667 Gane San kane endun colrado
    Now I have done this report using a query where I join table1 and table2 multiple times to get the report's data. And that query only works If the user has all attributes.If any one attribut is missing it wont work.Can some onehelp me with this.
    The query i am using looks like this.
    select a.accountnumber,a.firstname,a.lastname,b.attributevalue,c.attributevalue, d.attributevalue, e.attributevalue,f.attributevalue from table1 a,table2 b where a.id=b.id and a.id=c.id and a.id=d.id and a.id=e.id and a.id=f.id and b.attributename ='manager' and c.attributename ='lawyer' and d.attributename='system' and e.attributename='server' and f.attributename='location'
    this query works well if a user has all attributes ,if any one is missing he is not shown in the report.Can some one suggest me a good way of querying than this.
    The query I am using is also taking lot of time..I think I have explained my question well ,please reply if you have questions.
    Thanks for reading till here patiently,
    Pandu

    ....if this .....
    <DIV><B>
    <P><FONT face=Tahoma size=2>select</FONT></B><FONT size=2><FONT face=Tahoma>
    Accountnumber||</FONT><FONT face=Tahoma>' '||firstname||' '||lastname||'
    '||manager||' '||<B>System</B>||' '||Server||' '</FONT></FONT><FONT face=Tahoma
    size=2>||location<BR><B>from<SPAN
    class=940214002-13042006>     </SPAN></B>(<B>select</B>
    * <BR><B><SPAN
    class=940214002-13042006>             
    </SPAN>from<SPAN class=940214002-13042006>  </SPAN></B>(<B>select</B> '1'
    id, 'Sridh' firstname, 'Peter' lastname, 'SP456'</FONT><FONT face=Tahoma size=2>
    accountnumber <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                        
    </SPAN>select</B> '2' id, 'Gane' firstname, 'San' lastname, 'SS667'</FONT><FONT
    face=Tahoma size=2> accountnumber <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                          </SPAN>select</B>
    '3' id, 'Sway' firstname, 'patel' lastname, 'PP345'</FONT><FONT face=Tahoma
    size=2> accountnumber <B>from</B> dual) x,<BR><BR><SPAN
    class=940214002-13042006>           
    </SPAN>(<B>select</B> * <BR><B><SPAN
    class=940214002-13042006>             </SPAN>from</B>
    (<B>select</B> id,<BR><SPAN
    class=940214002-13042006>                                  </SPAN>attributename,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,0</FONT><FONT face=Tahoma size=2>) over (<SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id) <B>as</B> Manager,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,1</FONT><FONT face=Tahoma size=2>) over (<B><SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id</B>) <B>as</B> Lawyer,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,2</FONT><FONT face=Tahoma size=2>) over (<B><SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id</B>) <B>as</B> System,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,3</FONT><FONT face=Tahoma size=2>) over (<B><SPAN
    class=940214002-13042006><STRONG>partition by </STRONG>id </SPAN><B>order</B>
    <B>by</B> id<SPAN class=940214002-13042006>)</SPAN></B> <B>as</B>
    Server,<BR><SPAN
    class=940214002-13042006>                                 
    </SPAN>lead(attributevalue,4</FONT><FONT size=2><FONT face=Tahoma>) over
    (<B><SPAN class=940214002-13042006><STRONG>partition by </STRONG>id
    </SPAN><B>order</B> <B>by</B> id</B>) <B>as</B> Location<BR><B><SPAN
    class=940214002-13042006>                     
    </SPAN>from</B> (<B>select</B> *<SPAN class=940214002-13042006>
    </SPAN></FONT></FONT><FONT size=+0><FONT face=Tahoma><FONT size=2><B>from</B>
    (<B>select</B> '1' id, 'Manager' attributename, 'Mike'</FONT></FONT></FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '1' id, 'Lawyer' attributename, 'Schwa'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '1' id, 'Server' attributename, 'maneka'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                      
    </SPAN>select</B> '1' id, 'location' attributename, 'langur'</FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                      
    </SPAN>select</B> '1' id, 'System' attributename, 'Novel'</FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '2' id, 'Manager' attributename, 'kane'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '2' id, 'lawyer' attributename, 'endun'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                      
    </SPAN>select</B> '2' id, 'location' attributename, 'colrado'</FONT><FONT
    face=Tahoma size=2> attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '3' id, 'server' attributename, 'queen'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual <B>union</B><BR><B><SPAN
    class=940214002-13042006>                                                       </SPAN>select</B>
    '3' id, 'system' attributename, 'elanda'</FONT><FONT face=Tahoma size=2>
    attributevalue <B>from</B> dual)<BR><B><SPAN
    class=940214002-13042006>                                </SPAN>order</B>
    <B>by</B> id, (<B>case</B> <B>when</B> attributename='Manager' <B>then</B>
    1</FONT><FONT face=Tahoma size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='Lawyer' <B>then</B> 2</FONT><FONT face=Tahoma
    size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='System' <B>then</B> 3</FONT><FONT face=Tahoma
    size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='Server' <B>then</B> 4</FONT><FONT face=Tahoma
    size=2> <BR><B><SPAN
    class=940214002-13042006>                                                            
    </SPAN>when</B> attributename='Location' <B>then</B> 5</FONT><FONT
    face=Tahoma><FONT size=2> <B>end</B>) <B>asc</B>))<BR><B><SPAN
    class=940214002-13042006>           
    </SPAN>where</B> attributename='Manager'</FONT></FONT><FONT face=Tahoma size=2>)
    y<BR><B>where</B> x.id(+)=y.id)</FONT></P></DIV>
    < Jonel

  • How do I join two tables in the same database and load the result into a destination table in a SSIS package

    Hi,
    I have a query that joins two tables in the same database, the result needs to be loaded in a destination DB table.  How do I do this in SSIS package?
    thank you !
    Thank You Warmest Fanny Pied

    Please take a look at these links related to your query.
    http://stackoverflow.com/questions/5145637/querying-data-by-joining-two-tables-in-two-database-on-different-servers
    http://stackoverflow.com/questions/7037228/joining-two-tables-together-in-one-database

  • Joining two tables having no common fields using one select query

    Hi Experts,
    How to join two tables which are NOT having any field in common using only one select query?
    Your help will be appreciated.
    Thank you.

    Identify a third table (or more tables) with common fields with your two tables, or change your question either removing JOIN or removing NO COMMON FIELDS, else you wont get many responses and will be left alone in outer space, as suggested by Thomas.
    If you acturally require what you written, better execute two select and merge the two internal tables merging every record from first table with every record of second table, til no more memory is available.
    Regards,
    Raymond

  • How to  Join two tables using the Inner Join

    Hi All,
    I have two tables i.e table1 and table2 as i have created two otds and my present requirement is to join this two tables and get the results and using this i need to do some logic and update another table3.
    can some one help me out how to go for the above req.
    Thanks in Advance
    Srikanth

    The best efficient way to use inner join is create two input otds,use there otd's in create a collaboration usinf etl.
    after selecting two input otd's create a inner join statement and map it to out put otd.
    while using the etl the performance of the over all integration is increased 20 time of the normal integration.
    Hopes this will helps,,
    Thanks,
    Papa Rao.

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • How do you join two tables from different Oracle schemas using a subquery

    I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
    The query is as follows:
    sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
    + "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
    + "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
    + "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
    The format of the query is copied from a SQL programming manual.
    I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
    Edited by: user11338343 on Oct 19, 2009 6:55 AM

    I believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
    If you want to do a straight join without a subquery you could do the following
    SELECT  DD_12809.PDTABLE_12_1.LINE_ID
    ,       FAB.MAT_DESCRIPTION
    FROM    DD_12809.PDTABLE_12_1
    JOIN    RA_12809.PDTABLE_201    AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS  HTH!

  • How to prevent Oracle from using an index when joining two tables ...

    How to prevent Oracle from using an index when joining two tables to get an inline view which is used in an update statement?
    O.K. I think I have to explain what I mean:
    When joining two tables which have many entries sometimes it es better not to use an index on the column used as join criteria.
    I have two tables: table A and table B.
    Table A has 4.000.000 entries and table B has 700.000 entries.
    I have a join of both tables with a numeric column as join criteria.
    There is an index on this column in table A.
    So I instead of
      where (A.col = B.col)I want to use
      where (A.col+0 = B.col)in order to prevent Oracle from using the index.
    When I use the join in a select statement it works.
    But when I use the join as inline view in an update statement I get the error ORA-01779.
    When I remove the "+0" the update statement works. (The column col is unique in table B).
    Any ideas why this happens?
    Thank you very much in advance for any help.
    Regards Hartmut

    I think you should post an properly formatted explain plan output using DBMS_XPLAN.DISPLAY including the "Predicate Information" section below the plan to provide more details regarding your query resp. update statement. Please use the \[code\] and \[code\] tags to enhance readability of the output provided:
    In SQL*Plus:
    SET LINESIZE 130
    EXPLAIN PLAN FOR <your statement>;
    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);Usually if you're using the CBO (cost based optimizer) and have reasonable statistics gathered on the database objects used the optimizer should be able to determine if it is better to use the existing index or not.
    Things look different if you don't have statistics, you have outdated/wrong statistics or deliberately still use the RBO (rule based optimizer). In this case you would have to use other means to prevent the index usage, the most obvious would be the already mentioned NO_INDEX or FULL hint.
    But I strongly recommend to check in first place why the optimizer apparently seems to choose an inappropriate index access path.
    Regards,
    Randolf
    Oracle related stuff:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle:
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Joining two tables in PL/SQL

    Hi there,
    I have two problems...first being:
    We are trying to run a sub-query within a WHERE/AND clause. I am not sure on the correct syntax on how to run the sub-query as denoted in the code below. Secondly I am trying to join two tables with a common column name (ie: CIPIDI_NR). Considering I cant fix the first problem I cant test out the sub-query. So any help on either would be grateful. Cheers
    Select *
    from TBL_CIPIDI
         WHERE CIPIDI_NR like nvl ('in_case_number%', CIPIDI_NR)
    AND CIPIDI_NAME like nvl ('in_case_name%', CIPIDI_NAME)
    AND COST_CENTRE LIKE NVL ('in_cost_centre%', COST_CENTRE)
    AND CIPIDI_DESCRIPTION like nvl ('in_description%', CIPIDI_DESCRIPTION)
    AND CLAIMANT_NAME LIKE NVL ('in_claimant%', CLAIMANT_NAME)
    AND REQUESTOR LIKE NVL ('in_requestor%', REQUESTOR)
    AND PROJECT_MANAGER LIKE NVL ('in_project_manager%', PROJECT_MANAGER)
    AND TEAM_LEADER LIKE NVL ('in_team_leader%', TEAM_LEADER)
         AND ********RUN THE QUERY BELOW************
    SELECT C1.CIPIDI_NR, C2.CIPIDI_NR
    from TBL_TEAM_MEMBERS C1, TBL_CIPIDI C2
         WHERE C1.CIPIDI_NR = C2.CIPIDI_NR
         AND TEAM_MEM_NAME LIKE NVL ('in_team_mem_name%', TEAM_MEM_NAME)
    );

    You really need to start providing create table and insert statements for tables and sample data for testing, the results that you want based on that data in order to clarify the problem, your Oracle version, and a copy and paste of an attempted run of your code, complete with any error messages received. The following is my best guess at what you might be looking for.
    Select *
    from   TBL_TEAM_MEMBERS C1, TBL_CIPIDI C2
    WHERE  C1.CIPIDI_NR = C2.CIPIDI_NR
    AND    c1.CIPIDI_NR          like nvl (in_case_number     || '%', c1.CIPIDI_NR)
    AND    c1.CIPIDI_NAME        like nvl (in_case_name       || '%', c1.CIPIDI_NAME)
    AND    c1.COST_CENTRE        LIKE NVL (in_cost_centre     || '%', c1.COST_CENTRE)
    AND    c1.CIPIDI_DESCRIPTION like nvl (in_description     || '%', c1.CIPIDI_DESCRIPTION)
    AND    c1.CLAIMANT_NAME      LIKE NVL (in_claimant        || '%', c1.CLAIMANT_NAME)
    AND    c1.REQUESTOR          LIKE NVL (in_requestor       || '%', c1.REQUESTOR)
    AND    c1.PROJECT_MANAGER    LIKE NVL (in_project_manager || '%', c1.PROJECT_MANAGER)
    AND    c1.TEAM_LEADER        LIKE NVL (in_team_leader     || '%', c1.TEAM_LEADER)
    AND    TEAM_MEM_NAME         LIKE NVL (in_team_mem_name   || '%', TEAM_MEM_NAME);

  • Script to compare 2 tables and retrieve the differences in records data

    Dear All,
    please I need a script to compare two oracle database tables and retrieves the differences in data records between the two tables.
    I have tried this one :
    -- all rows that are in T1 but not in T2
    (select * from T1 minus select * from T2)
    union all
    -- all rows that are in T2 but not in T1
    (select * from T2 minus select * from T1);
    But it generates the following error:
    ORA-01789: query block has incorrect number of result columns
    Thank you for your cooperation , please it is urgent

    ok I used this statement with dblink, the problem is that i cannot use PL/SQL developer since it is a process repeated for 300 tables , that why i am trying to automate it:
    -- all rows that are in T1 but not in T2
    (select * from schema.T1minus select * from T2@dblink_name)
    union all
    -- all rows that are in T2 but not in T1
    (select * from T2@dblink_name minus select * from schema.T1);
    I created the db link on a database A and when i run the statement
    (select * from schema.T1minus select * from T2@dblink_name)
    on the database B i get the error ORA-02019: CONNECTION DESCRIPTION FOR REMOTE DATABASE NOT FOUND.
    DOes anybody have an idea please

Maybe you are looking for

  • How to capture Button Click in OAF

    Hi All, I have created a button "TestButton" using personalization. On the click of this button, a new page "TestPG" opens. But i have to pass a few parameters from the old page to the new page. How do i capture this button click event in the CO so t

  • Start Navigation sound in Windows 7 64 bit dissappeared

    ? [size="">I have been scratching my head over this one. [size="">After doing a clean install of Windows 7 64 bit on a new build this week, and installing a new X-Fi PCIe Titanium Fatality Pro, I found the start navigation windows sound was no longer

  • Problem while reading data  from USB with JSR80

    Hi Iam using Fedora 9 with 32 bit. Iam using JSR80 api to read the data from USB devices. I successfully set-up the code as per given on JSR80 site on my eclipsce ide. below is my code which iam using to read data from usb import com.ibm.jusb.*; impo

  • "Please check your network settings and try again....

    lately every time I try to sign into Skypemon my IPad. Does anyone know if this is an technical issue that I would have to call my Internet provider(AT&T) about or would have to call tech support at Apple about? Thank you!

  • Scanning: The image size is too big. Please reduce the image height, width, resolution, scaling or output type.

    Good Day. I have recently discovered an issue with scanning.  I have tried scanning straight from the printer, through image capture, and through preview.  All yeilding the same results since they are essentailly kicking off the same scanning applet.