JOIN 2 tables that have same column ?

I need to learn how to join two tables that both have the same column name:
tbl1 - idskey
tbl2 - idskey
the idskey column holds a id_number
When I do the JOIN I would like to make sure that only Distinct records are joined from both tables and that any duplicates are removed in the final join. So if:
Tbl1 has a idskey of: 12345
and
Tbl2 has a idskey of: 12345
In the final JOIN I want to remove one of those duplicates.
I actually need to join 3 tables that have the same linking column names for the join, but if I learn how to do this correctly on 2, that will be a start.
10g for db, thanks!

Hi,
SELECT DISTINCT and GROUP BY are the most common ways to get unique results from non-unique keys. Exactly how you use them depends on exactly what you want to do.
SELECT DISTINCT guarantees that no two rows in the result set, conisdering all columns, will be identical.
GROUP BY produces one row from a set of rows that have a common feature. The values on that row may be a composite of values from various rows in that set (e.g., an average).
Please post a small, specific example. For instance:
"I have two rows in tbl1 ...
and these fhtee rows in tbl2 ...
Notice how there is one row with idskey=12345 in tbl1 but two such rows in tbl2.
How can I get theses results ...
where only one row has idskey=12345?"

Similar Messages

  • Trying to join two views that have different column types

    I want to join view1 and view2 on region and city int columns. Need to break apart View1 varchar field into two Int fields and replace any non-numeric values with zeros.
    View1 has a single Region_City field that is VARCHAR. the last record is erroneous. the individual values for Region and City should always be Int. 
    0001-8374
    0222-0034
    3333-0001
    XXA-EEE
    View2 has Region and City as two seperate Int columns (i will seperate with comma just for display)
    Region,City
    1,8374
    222,34
    3333,1
    I want to create two new individual columns in view1 that will have Region and City each as a Int. And for any Region_city that is invalid numeric just use zeros in Region and City.
    I currently have this (in house ParseDelimited sproc), but am having trouble with the invalid numeric values (XXAA-EEE)
    REPLACE(LTRIM(REPLACE(dbo.ParseDelimited (Region_City, '-', 1), '0', ' ')), ' ', '0') as Region,
    REPLACE(LTRIM(REPLACE(dbo.ParseDelimited (Region_City, '-', 2), '0', ' ')), ' ', '0') as City,

    This is a way to do it, by no means the only way, but a way.  (The other way to achieve this would work fine, but would require functions inside functions inside other functions, including repeating at the very least "Patindex('-', RegionCity)"
    a few times.  In this situation, the APPLY statement comes in handy by making it a little easier to read.
    Declare @ExampleTable Table (RegionCity Varchar(99))
    Insert @ExampleTable /* This is just to recreate a test table */
      Select '0001-8374'
      UNION ALL Select '0222-0034'
      UNION ALL Select '3333-0001'
      UNION ALL Select 'XXA-EEE'
      UNION ALL Select 'a really bad error, no numbers or dash at all'
      UNION ALL Select '1-2'
      UNION ALL Select '12345678-98765432'Select RegionCity
        , Cast(  Coalesce( Case When IsNumeric(RegionCode) = 1 then RegionCode else '0000' End, '0000') as Int)  as RegionCode
        , Cast( Coalesce( Case When IsNumeric(CityCode) = 1 then CityCode Else '0000' End, '0000') as Int) as CityCode
      From @ExampleTable
     Outer Apply (Select CharIndex('-', RegionCity) as DashPos) CaDash
     Outer Apply (Select Substring(RegionCity, 1, DashPos - 1) as RegionCode
                        , SubString(RegionCity, DashPos + 1, 99) as CityCode where DashPos > 0) as CA2
    You didn't mention how bad the source data might be, how unpredictable it might be, whether it's always coded exactly as listed.  This way is reasonably flexible.
    EDIT: I used "IsNumeric" in this example.  It's quite an imperfect function, often best avoided, but I used here just because it's probably OK in this example.  
    This is probably better:  "Case When PatIndex('%[^0123456789]%', CityCode) = 0 Then CityCode else 0 End"

  • When migrating from 10g to 11g with tables that have LOB columns, should the columns be converted to Securefile LOB formats?

    We have an ongoing debate over the merits of switching to securefile LOBS. This is Oracle recommended approach but what are the main benefits?
    Thsi would allow parallel impdp to take place also has benefit for compression, but are there any other driving factors to consider?

    The fact that a hacking solution works well with a particular binary file on a particular database does not guarantee that it will not destroy another file and another database beyond repair. In case this happens, people will call Oracle Support for help. And Oracle Support may refuse (though it tries not to do this without reason) to help with such a corrupted database. This is a consequence of "unsupported" modifications to binary files. Therefore, publishing this type of advice with little or no word of warning nor disclaimer is simply irresponsible (especially, if simpler and supported solutions exist).
    I did not suggest that you should waste time checking if your particular solution had already been documented or not but I did suggest that you see if the methods you proposed were documented. And, frankly speaking, this is not what an Oracle DBA should really have to check. I also cannot believe that you are not aware that modification of files in any undocumented binary format (not only Oracle's) is generally unsupported. And, while common and somehow acceptable in low-risk home or research applications, such modifications are a bad idea in high-risk production business use.
    -- Sergiusz

  • Can I create a view based on two tables that have the same column name?

    I have two tables A and B. Each table has 50+ columns.
    I want to create a view that includes all the columns in A and all the columns in B. I created a view with a select statement that says
    Select A.*, B.*
    From A, B
    where A.id = B.id
    It returns an error because in each table I have a column that keeps track if a record has been changed called Modified_By. That's where it chokes up on I figure. I would like to write the view without explicitly writing each column name from A and B as part of the select statement. The actual select statement works fine and only bombs when trying to turn the select statement into a view.

    You will have to type the full column list at least once. You can save a few keystrokes (i.e. alias. on every column) by providing the column names to the CREATE part instead of in the SELECT part. Something like:
    SQL> desc t
    Name                                      Null?    Type
    ID                                                 NUMBER
    NAME                                               VARCHAR2(10)
    SQL> desc t1
    Name                                      Null?    Type
    T_ID                                               NUMBER
    LOC_ID                                             NUMBER
    NAME                                               VARCHAR2(15)
    SQL> CREATE VIEW t_v (id, t_name, t_id, loc_id, t1_name) AS
      2  SELECT t.*, t1.*
      3  FROM t, t1
      4  WHERE t.id = t1.t_id;
    View created.HTH
    John

  • Deleting from multiple tables where few tables have same column name

    Hi,
    I am new to PL/SQL and need some help. I need to delete data older then X years from some 35 odd tables in my schema and out of those tables 25 tables have same column name on which i can have my "where" clause and rest 10 table have different table names. I am doing something like this :
    declare
    table_list UTL_FILE.FILE_TYPE;
    string_line VARCHAR2(1000);
    tables_count number:=0;
    table_name VARCHAR2(400);
    column_name VARCHAR2(400);
    BEGIN
    table_list := UTL_FILE.FOPEN('ORALOAD','test7.txt','R');
    DBMS_OUTPUT.PUT_LINE(table_list);
    LOOP
    UTL_FILE.GET_LINE(table_list,string_line);
    table_name := substr(string_line,1, instr(string_line,'|')-1);
    column_name := substr(string_line, instr(string_line,'|')+1);
    DBMS_OUTPUT.PUT_LINE(table_name);
    DBMS_OUTPUT.PUT_LINE(column_name);
    IF column_name = 'SUBMISSION_TIME' THEN
    delete from :table_name where to_date(:column_name)<(sysdate-(365*7));
    ELSE
    delete from || table_name || where ( || to_date(column_name) || ) <(sysdate-(365*7));
    END IF;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    UTL_FILE.FCLOSE(table_list);
    DBMS_OUTPUT.PUT_LINE('Number of Tables processed is : ' || tables_count);
    UTL_FILE.FCLOSE(table_list);
    END;
    WHERE the text file "text7.txt" contains list of table name and column names separated by a pipe line. But when I execute the above proc it gives error "invalid table name".
    Can something like this be done or is there any other way to execute this task of deletion from 35 tables.
    Thanks.

    Thanks for replies. I don't know what I am doing wrong but still not getting this damn thing work...This is the proc i am running now :
    declare
    table_list UTL_FILE.FILE_TYPE;
    string_line VARCHAR2(1000);
    tables_count number:=0;
    table_name VARCHAR2(4000);
    column_name VARCHAR2(4000);
    code_text VARCHAR2(2000);
    BEGIN
    table_list := UTL_FILE.FOPEN('ORALOAD','test7.txt','R');
    LOOP
    UTL_FILE.GET_LINE(table_list,string_line);
    table_name := substr(string_line,1, instr(string_line,'|')-1);
    column_name := substr(string_line, instr(string_line,'|')+1);
    IF column_name = 'SUBMISSION_TIME' THEN
    DBMS_OUTPUT.PUT_LINE('do nothing');
    ELSE
    code_text:= 'begin delete from'|| (table_name) ||'where to_date' || (column_name) || '<(sysdate-(365*7))';
    Execute Immediate code_text;
    END IF;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    UTL_FILE.FCLOSE(table_list);
    DBMS_OUTPUT.PUT_LINE('Number of Tables processed is : ' || tables_count);
    UTL_FILE.FCLOSE(table_list);
    END;
    But it gives following error :
    " ORA-06550: line 1, column 51:
    PL/SQL: ORA-00933: SQL command not properly ended
    ORA-06550: line 1, column 7:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 1, column 68:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    ORA-06512: at line 22 "

  • 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

  • Best way to outer join a table that is doing a sub query

    RDBMS : 11.1.0.7.0
    Hello,
    What is the best way to outer join a table that is doing a sub query? This is a common scenario in EBS for the date tracked tables.
    SELECT papf.full_name, fu.description
      FROM fnd_user fu
          ,per_all_people_f papf
    WHERE fu.user_id = 1772
       AND fu.employee_id = papf.person_id(+)
       AND papf.effective_start_date = (SELECT MAX( per1.effective_start_date )
                                          FROM per_all_people_f per1
                                         WHERE per1.person_id = papf.person_id)Output:
    No output produced because the outer join cannot be done on the sub queryIn this case I did a query in the FROM clause. Is this my best option?
    SELECT papf.full_name, fu.description
      FROM fnd_user fu
          ,(SELECT full_name, person_id
              FROM per_all_people_f papf
             WHERE papf.effective_start_date = (SELECT MAX( per1.effective_start_date )
                                                  FROM per_all_people_f per1
                                                 WHERE per1.person_id = papf.person_id)) papf
    WHERE fu.user_id = 1772
       AND fu.employee_id = papf.person_id(+)Output:
    FULL_NAME     DESCRIPTION
    {null}            John DoeThanks,
    --Johnnie                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    BrendanP wrote:
    ... See the adjacent thread for the other with Row_Number().Do you mean {message:id=10564772} ? Which threads are adjacent is always changing. Post a link.
    I think RANK suits the requirements better than ROW_NUMBER:
    WITH    all_matches     AS
         SELECT  papf.full_name
         ,      fu.description
         ,     RANK () OVER ( PARTITION BY  papf.person_id
                               ORDER BY          papf.effective_start_date     DESC
                        )           AS r_num
         FROM             fnd_user             fu
         LEFT OUTER JOIN      per_all_people_f  papf  ON  fu.employee_id  = papf.person_id
         WHERE   fu.user_id  = 1772
    SELECT     full_name
    ,     description
    FROM     all_matches
    WHERE     r_num     = 1
    Johnnie: I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    See the forum FAQ {message:id=9360002}

  • Shadow tables that have been created via the new partitioning schema

    Hi,
         Complete Partitioning :
                    In a complete partitioning, the fact table of the infocube are fully converted using shadow
    tables that have been created via the new partitioning schema.
                   in the above Explanation what is the meaning of shadow tables which perform the
                   partitioning of an info cube.

    Hi
    Shadow tables have the namespace /BIC/4F<Name of InfoCube> or /BIC/4E<Name of InfoCube>.
    Complete Partitioning
    Complete Partitioning fully converts the fact tables of the InfoCube. The system creates shadow tables with the new partitioning schema and copies all of the data from the original tables into the shadow tables. As soon as the data is copied, the system creates indexes and the original table replaces the shadow table. After the system has successfully completed the partitioning request, both fact tables exist in the original state (shadow table), as well as in the modified state with the new partitioning schema (original table). You can manually delete the shadow tables after repartitioning has been successfully completed to free up the memory. Shadow tables have the namespace /BIC/4F<Name of InfoCube> or /BIC/4E<Name of InfoCube>.
    You can only use complete repartitioning for InfoCubes. A heterogeneous state is possible. For example, it is possible to have a partitioned InfoCube with non partitioned aggregates. This does not have an adverse effect on functionality. You can automatically modify all of the active aggregates by reactivating them.
    Hope it helps and clear

  • How to improve Oracle Veridata Compair pair performance with tables that have big (30-40MB)CLOB/BLOB fileds ?

    How to improve Oracle Veridata Compair pair performance with tables that have big (30-40MB)CLOB/BLOB fileds ?

    Can you use insert .. returning .. so you do not have to select the empty_clob back out.
    [I have a similar problem but I do not know the primary key to select on, I am really looking for an atomic insert and fill clob mechanism, somone said you can create a clob fill it and use that in the insert, but I have not seen an example yet.]

  • Best way to join 2 columns from table A to same column in Table B?

    Hi,
    This is a simplified example of the query I'm trying to write.
    I have two tables - PIPELINE (which includes columns CREDIT_RECEIVER and CREATOR) and EMPLOYEES (which includes columns EMAIL and LOB).
    I want to write a query which joins PIPELINE.CREDIT_RECEIVER with EMPLOYEES.EMAIL to return LOB as "CREDIT_RECEIVER_LOB".
    I also want this query to join PIPELINE.CREATOR with EMPLOYEES.EMAIL to return LOB as "CREATOR_LOB".
    Currently, I am doing a left outer join on EMPLOYEES.EMAIL = PIPELINE.CREDIT_RECEIVER to get "CREDIT_RECEIVER_LOB", and calling a function GET_LOB(PIPELINE.CREATOR) (defined below) to get "CREATOR_LOB".
    Query:
    Select PIPELINE.ID as ID,
    PIPELINE.CREDIT_RECEIVER as CREDIT_RECEIVER,
    PIPELINE.CREATOR as CREATOR,
    EMPLOYEES.LOB as CREDIT_RECEIVER_LOB,
    GET_LOB(PIPELINE.CREATOR) as CREATOR_LOB
    FROM PIPELINE
    LEFT OUTER JOIN EMPLOYEES ON PIPELINE.CREDIT_RECEIVER=EMPLOYEES.EMAIL
    Is there a more efficient way to write this query? This query is so slow that it usually times out on me.
    Thanks,
    Forrest
    GET_LOB definition
    create or replace function "GET_LOB"
    (vemail in VARCHAR2)
    return VARCHAR2
    is
    begin
    DECLARE vLOB VARCHAR2(30);
    BEGIN
    SELECT LOB INTO vLOB FROM EMPLOYEES WHERE email = vemail;
    return vLOB;
    END;
    end;

    Select PIPELINE.ID as ID,
           PIPELINE.CREDIT_RECEIVER as CREDIT_RECEIVER,
           PIPELINE.CREATOR as CREATOR,
           e1.LOB as CREDIT_RECEIVER_LOB,
           e2.LOB as CREATOR_LOB
      FROM PIPELINE
      LEFT OUTER JOIN EMPLOYEES E1
        ON PIPELINE.CREDIT_RECEIVER = EMPLOYEES.EMAIL
      LEFT OUTER JOIN EMPLOYEES E2
        ON PIPELINE.CREATOR = EMPLOYEES.EMAIL
    Ramin Hashimzade

  • How do I select rows from the same table that have multiple occurances

    Hi Everybody,
    I am trying to select records from a detail table by grouping it. The table has more than 1 million records and the query is not performing well. The basic question is how to select a distinct record from a table which matches all values in one column and any in the other.
    desc SCV
    ID NUMBER PK (ID + SCRID)
    SCRID NUMBER FK(SC)
    ID SCRID
    1 1
    2 1
    3 1
    4 2
    5 2
    6 3
    7 4
    8 4
    desc PROJECTS
    ID NUMBER PK
    NAME VARCHAR2(100)
    ID NAME
    1 PROJECT1
    2 PROJECT2
    3 PROJECT3
    4 PROJECT4
    desc PJS
    ID NUMBER
    PROID NUMBER FK (PROJECTS)
    SCRID NUMBER FK (SCV(SCRID + SCVID)
    SCVID NUMBER
    ID PROID SCRID SCVID
    1 1 1 1
    2 1 1 2
    3 1 2 5
    4 1 3 6
    5 1 4 7
    6 2 1 3
    7 2 2 4
    8 2 2 5
    9 2 4 7
    There are over 1 million records in PJS.
    desc TBP
    SCRID NUMBER
    SCVID NUMBER
    SCRID SCVID
    1 1
    1 2
    1 3
    2 4
    2 5
    3 6
    4 7
    4 8
    The requirement is to select projects that have matching SCRID, SCVID from TBP such that
    all distinct SCRID should match and within that and any SCVID match will do. (A "AND" between each SCRID and an "OR" for each SCVID in that SCRID like 'SCRID = 1 AND (SCVID = 1 OR SCVID = 2 OR SCVID = 3) AND SCRID = 2 AND (SCVID =....)
    So, for the sample data it should return us PROID = 1
    I have few queries written for this:
    SELECT PROID FROM PJS,TBP WHERE TBP.SCVID = PJS.SCVID AND TBP.SCRID = 1
    INTERSECT
    SELECT PROID FROM PJS,TBP WHERE TBP.SCVID = PJS.SCVID AND TBP.SCRID = 2
    INTERSECT
    SELECT PROID FROM PJS,TBP WHERE TBP.SCVID = PJS.SCVID AND TBP.SCRID = 3
    INTERSECT
    SELECT PROID FROM PJS,TBP WHERE TBP.SCVID = PJS.SCVID AND TBP.SCRID = 4
    This query performs well but the cost is very high, hardcoding, sorting.
    The 2nd option is to:
    SELECT pjs.PROID proid
    FROM TBP tbp,
    PJS pjs
    WHERE pjs.SCVID = tbp.SCVID
    AND pjs.SCRID = tbp.SCRID
    GROUP BY pjs.PROID
    HAVING COUNT(DISTINCT pjs.SCRID) = (SELECT COUNT(DISTINCT SCRID ) FROM TBP)
    This has a low cost but runs slowly.
    One more way I tried was with the IN operator like
    SELECT DISTINCT PROID FROM PJS A,TBP T WHERE T.SCRID = 1 AND T.SCVID = A.SCVID
    AND PROID IN (SELECT PROID FROM PJS A,TBP T WHERE T.SCRID = 2 AND T.SCVID = A.SCVID
    AND PROID IN (...SO ON with each DISTINCT SCRID.
    Again this involves too much of sorting.
    Any help will be appriciated.
    Thanks in advance.

    Hi Andrew,
    Use DELETE t_itab statement inside the loop.
    I have modified your code. It is perfectly working.See bellow  -
    LOOP AT it_zmember01 INTO wa_zmember01.
    WRITE: / wa_zmember01-mnumber UNDER 'NUMBER',
    wa_zmember01-mname UNDER 'NAME',
    wa_zmember01-mdob UNDER 'DOB'.
    WRITE / '-----------------------------------------------------------------'.
    DELETE it_zmember01.               " Modified
    ENDLOOP.
    DELETE it_zmember01. statement inside the loop will delete the current row of the table.
    Regards
    Pinaki

  • Update a column in each row in my table that have similar values in another column

    Hi All,
    I have a table in my DB.
    This table has values like this:
    Name
    Key
    a
    1
    a
    2
    a
    3
    a
    2
    b
    4
    b
    5
    b
    5
    I need to change the name to a different name for keys that are different. For same keys, the name must be same.
    Here I need to rename the 'a' to different name, but make sure that the 'a' that have 2 as the key have same name .
    Similarly, i've to rename the 'b' to different name , but make sure that the 'b' that have 5 as the key have the same name.
    How can I achieve this in sql? I dont know how to use cursor and complex queries, as i'm new to SQL.
    Please help
    Thanks,
    Vid
    Vidya Suryanarayana

    Ok. The output should be like this:
    Note here, that the names with same keys have same names.
    name
    key
    a1
    1
    a2
    2
    a3
    3
    a2
    2
    b1
    4
    b2
    5
    b2
    5
    Thanks,
    Vid
    Vidya Suryanarayana

  • Counting Numnber of Cells in a Table that Have the Same Value

    Is there a way/formula to do this, other than they way I'm doing it now, which is by using COUNTIF? In a table with 1000 rows for instance, let's say the values in the A column are what I'm keying off. I would like a count of all the cells in the A column that have the word "example" as their value. Right now for each unique value in a cell in the A column I am manually creating a COUNTIF(A1:A1000,"<value i'm matching against>) but if there are many unique values in the A column, it's quite laborious. Ideally I'd like to just have a table generated that gives me the top 5 or top 10 most occurring cell values in the A column in the table. What's the best way to do this?

    So for instance, for a column like this:
    1
    1
    1
    2
    2
    4
    5
    I want a way to get back the number of times 1 appears in the list (3), the number of times 2 appears in the list (2), 4 (1), 5 (1), and so on. If I do a COUNTIF and there are thousands of rows, I have to manually put the matching string in each one.

  • How to join two tables with no similar columns

    Hi all,
    I have two tables as follows:
    Table T1 have Attributes as follows:
    GLCODE,
    BRANCH,
    ITEM_NUMBER,
    DEMAND_DATE,
    QUANTITY,
    SOURCE
    Table T2 have Attributes as follows:
    FORECAST_DATE
    Now in SQL if run the following stattement iam getting out put.
    SELECT GLCODE,BRANCH,ITEM_NUMBER,DEMAND_DATE,QUANTITY, SOURCE,(SELECT DISTINCT FORECAST_DATE FROM T2) FROM T1
    The above SQL Statement giving correct results for me.
    The same SQL Statement how can we implement in mapping level?
    Regards,
    Ava

    Jaap van,
    >
    You have to specify an outer join, but how do you do that if there is no join to begin with? I would do the following (which I didn't test yet):
    add an extra column (say C_JOIN) to the T2-ingroup of the join operator and fill it with from a constant operator with say value 1. Then use T2.C_JOIN (+) = 1 as the join condition.
    If every record in T2 is guaranteed to have the same value, instead of using a deduplicator, which will read all records, sort them and deduplicate them, you can use a filter with filter condition ROWNUM < 2, which only will read one record.
    I am facing almost the same problem but not entirely thou and I was wondering if you have an idea how to even start.
    Problem:
    I got this table:SQL> desc ita.tpis32_job_status
    Name Null? Type
    JOBID NOT NULL NUMBER
    T1_ID NUMBER
    QID NUMBER
    REQ_TYPE VARCHAR2(10)
    SUBMIT_TIME DATE
    OWNERID VARCHAR2(30)
    DESCRIPTION VARCHAR2(150)
    STARTTIME DATE
    ENDTIME DATE
    STATUS VARCHAR2(50)
    ERROR_ID NUMBER
    TABLE_NAME VARCHAR2(30)
    SERVER_ID VARCHAR2(10)
    DATABASE VARCHAR2(20)
    PRIORITY NUMBER
    NUM_LINES NUMBER
    PROCESS_ID NUMBER
    QUE_TIME NUMBER
    STATUS_CODE NUMBER
    ERROR_MSG VARCHAR2(500)
    NUM_LINES_TS NUMBER
    REMOTE_STATUS NUMBER
    This the above table, i am looking for JOBID (a five digit number) like 25875.
    What I want to do is add or append this five digit number to a string to find the corresponding table in dba_tables or all_tables. The only way I have try to do this is by writing PLSQL as you see from here:
    Re: Use PLSQL to delete tables dynamically
    When the select is writing properly, the result of the five digit number from JOBID and the string should look like the below result (job_(five digit_%).
    My problem is there is no relationship between ALL_TABLES and the my own table (ita.tpis32_job_status). Any help will be appreciated.
    TABLE_NAME
    JOB_58871_OUTDATA
    JOB_58868_TS
    JOB_58868_OUTDATA
    JOB_58867_TS
    JOB_58867_CMDLBL_2
    JOB_58867_OUTDATA
    JOB_58866_TS

  • How To Create Table View With Same Column name But Different Table?

    Hi All,
    I have the problem to create a tableview with same column name but in different table.
    The Table that i have:-
    Table - PAC051MPROFORMA
    Column - mrn,visitid
    Table - PAC051TPROFORMA
    Column - mrn,visitid
    Table - PAC052MTRANSBILL
    Column - mrn,visitid
    Then i want to create a table view to view that table. This is my SQL
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    That SQL Return this error = ORA-00957: duplicate column name
    Then I modify that SQL to
    CREATE VIEW pacviewproforma (mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    This time this error return = ORA-01730: invalid number of column names specified
    What should i do?
    Thanks...

    Hi,
    SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    ERROR at line 1:
    ORA-00957: duplicate column namePlease give different names to each column.
    Something like this..
    SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
    _visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    View created.
    SQL> DESC  pacviewproforma;
    Name                                      Null?    Type
    MPROFORMA_MRN                                      NUMBER
    MPROFORMA_VISITID                                  NUMBER
    TPROFORMA_MRN                                      NUMBER
    TPROFORMA_VISITID                                  NUMBER
    MTRANSBILL_MRN                                     NUMBER
    MTRANSBILL_VISITID                                 NUMBER
    ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
    Twinkle

Maybe you are looking for

  • Can I upgrade to Mountain Lion with my 2008 MAcbook Pro?

    I have a 2008 MAcbook pro 10.6.8 , 2,5 GHz Intel duel core, 4 GB MHz 17 Inch.    It works fine but I am about to receive a new iPhone 5 and want to use iCloud. Is my computer compatible with doing this? ANd what will be different if I do? Will my com

  • Variable Function Names

    What I'm trying to do is add event listeners for each position up to the total of compPositions. This way, each one will have a dymanic function name. Right now, they all launch function "clicked1" but I can't figure out how to make it add numbers to

  • Wrong board, I know, but I don't know how to use Parallels...

    Can someone walk me through installing Win XP on Parallels? The help menu doesn't, and I can't find a forum on their own site. Is it easier than it looks? The software looks so complicated to me.

  • Spam/Saint update failed

    Hello, My current SPAM/SAINT version is 20. I tried updating it to version 38. But while updaing m facing a runtime error  which is generating a short dump. Short Text of dump is as follows: Syntax error in program "CL_OCS_RT_ANALYSIS============CP W

  • Error in FM: SXPG_COMMAND_EXECUTE

    Hi, I am using FM: SXPG_COMMAND_EXECUTE to encrypt file for appication server but i am getting below errors: - Can't exec external program (Unknown error) - WaitForSingleObject failedwith %d (No such device or address) Can you please suggest me on th