Please help - Joining three tables and get row values into Column. Please help!

Hi,
There is a SourceTable1 (Employee) with Columns like EmployeeID,Name,DOB.
There is a sourcetable2 (EmployeeCode) with columns like EmployeeID,Code,Order.
There is a source table 3  #EmployeeRegioncode  and its columns are (EmployeeID , RegionCode , [Order] 
The target table 'EmployeeDetails' has the following details. EmployeeID,Name,DOB,Code1,Code2,Code3,Code4,regioncode1
regioncode2 ,regioncode3 ,regioncode4 
The requirement is , the value of the target table columns the Code1,code2,code3 ,code4,code5 values should
be column 'Code' from Sourcetable2 where its 'Order' column is accordingly. ie) Code1 value should be the 'Code' value where [Order] column =1, and Code2 value should be the 'Code' value where [Order] =2, and so on.
Same is the case for Source table 3- 'Region code' column also for the columns  regioncode1
regioncode2 ,regioncode3 ,regioncode4 
Here is the DDL and Sample date for your ref.
IF OBJECT_ID('TEMPDB..#Employee') IS NOT NULL DROP TABLE #Employee;
IF OBJECT_ID('TEMPDB..#EmployeeCode') IS NOT NULL DROP TABLE #EmployeeCode;
IF OBJECT_ID('TEMPDB..#EmployeeDetails') IS NOT NULL DROP TABLE #EmployeeDetails;
---Source1
CREATE table #Employee 
(EmployeeID int, Empname varchar(20), DOB date )
insert into #Employee VALUES (1000,'Sachin','1975-12-12') 
insert into #Employee VALUES (1001,'Sara','1996-12-10') 
insert into #Employee  VALUES (1002,'Arjun','2000-12-12')
---Source2
CREATE table #EmployeeCode 
(EmployeeID int, Code varchar(10), [Order] int)
insert into #EmployeeCode VALUES (1000,'AA',1) 
insert into #EmployeeCode VALUES (1000,'BB',2)   
insert into #EmployeeCode  VALUES (1000,'CC',3)  
insert into #EmployeeCode VALUES  (1001,'AAA',1)  
insert into #EmployeeCode  VALUES  (1001,'BBB',2)  
insert into #EmployeeCode  VALUES  (1001,'CCC',3)  
insert into #EmployeeCode  VALUES  (1001,'DDD',4)  
insert into #EmployeeCode  VALUES  (1002,'AAAA',1)  
insert into #EmployeeCode  VALUES  (1002,'BBBB',2)  
insert into #EmployeeCode  VALUES  (1002,'CCCC',3)  
insert into #EmployeeCode  VALUES  (1002,'DDDD',4)  
insert into #EmployeeCode  VALUES  (1002,'EEEE',5)  
---Source tbl 3
CREATE table #EmployeeRegioncode 
(EmployeeID int, RegionCode varchar(10), [Order] int)
insert into #EmployeeRegioncode VALUES (1000,'xx',1) 
insert into #EmployeeRegioncode VALUES (1000,'yy',2)   
insert into #EmployeeRegioncode  VALUES (1000,'zz',3)  
insert into #EmployeeRegioncode VALUES  (1001,'xx',1)  
insert into #EmployeeRegioncode  VALUES  (1001,'yy',2)  
insert into #EmployeeRegioncode  VALUES  (1001,'zz',3)  
insert into #EmployeeRegioncode  VALUES  (1001,'xy',4)  
insert into #EmployeeRegioncode  VALUES  (1002,'qq',1)  
insert into #EmployeeRegioncode  VALUES  (1002,'rr',2)  
insert into #EmployeeRegioncode  VALUES  (1002,'ss',3)  
---Target
Create table #EmployeeDetails
(EmployeeID int, Code1 varchar(10), Code2 varchar(10),Code3 varchar(10),Code4 varchar(10),Code5 varchar(10) , regioncode1 varchar(10),
regioncode2 varchar(10),regioncode3 varchar(10),regioncode4 varchar(10))
insert into #EmployeeDetails  VALUES (1000,'AA','BB','CC','','','xx','yy','zz','')  
insert into #EmployeeDetails  VALUES (1001,'AAA','BBB','CCC','DDD','','xx','yy','zz','xy')  
insert into #EmployeeDetails VALUES (1002,'AAAA','BBBB','CCCC','DDDD','EEEE','qq','rr','ss','')  
SELECT * FROM  #Employee
SELECT * FROM  #EmployeeCode
SELECT * FROM  #EmployeeRegioncode
SELECT * FROM  #EmployeeDetails
Can you please help me to get the desired /targetoutput?  I have sql server 2008.
Your help is greatly appreciated.

select a.EmployeeID,b.code1,b.code2,b.code3,b.code4,b.code5,c.Reg1,c.Reg2,c.Reg3,c.Reg4 from
#Employee a
left outer join
(select EmployeeID,max(case when [Order] =1 then Code else '' end) code1,
max(case when [Order] =2 then Code else '' end)code2,
max(case when [Order] =3 then Code else '' end)code3,
max(case when [Order] =4 then Code else '' end)code4,
max(case when [Order] =5 then Code else '' end)code5 from #EmployeeCode group by EmployeeID) b
on a.EmployeeID=b.EmployeeID
left outer join
(select EmployeeID,max(case when [Order] =1 then RegionCode else '' end) Reg1,
max(case when [Order] =2 then RegionCode else '' end)Reg2,
max(case when [Order] =3 then RegionCode else '' end)Reg3,
max(case when [Order] =4 then RegionCode else '' end)Reg4 from #EmployeeRegioncode group by EmployeeID) c
on a.EmployeeID=c.EmployeeID
Thanks
Saravana Kumar C

Similar Messages

  • Joining three tables to get totals on three columns.

    hi gurus,
    i have spent hours and hours to get the desired result with this join query. 98% of the query bring results according to my expectations but for some reasons few results are duplicating. let me give you the structure of my tables than my query and than what i expect it to bring. here we go;
    There are three tables
    *1. SENDER*
    Name Null? Type
    SNAME VARCHAR2(50)
    SPHONE1 NOT NULL VARCHAR2(15)
    SPHONE2 VARCHAR2(15)
    SPHONE3 VARCHAR2(15)
    SCITY VARCHAR2(25)
    SREMARKS VARCHAR2(200)
    IDENTIFICATION VARCHAR2(20)
    ADD1 VARCHAR2(30)
    ADD2 VARCHAR2(30)
    *2. TRANSACTION*
    Name Null? Type
    T_ID NOT NULL NUMBER
    SPHONE1 VARCHAR2(15)
    R_ID NUMBER
    RB_ID VARCHAR2(10)
    TRANSFER_TO VARCHAR2(25)
    TDATE DATE
    SOURCE VARCHAR2(20)
    CURR VARCHAR2(10)
    PAID VARCHAR2(10)
    MOP VARCHAR2(10)
    DOLLAR NUMBER
    RATE NUMBER(5,2)
    RUPPEE NUMBER
    TREM1 VARCHAR2(200)
    TREM2 VARCHAR2(100)
    PPAYMENT VARCHAR2(10)
    PROMISE VARCHAR2(50)
    BALANCE NUMBER
    DOLLAR2 NUMBER
    *3. PAYMENTS*
    Name Null? Type
    PAYMENT_ID NOT NULL NUMBER
    PDATE DATE
    SPHONE1 VARCHAR2(15)
    AMT_PAID NUMBER
    BALANCE NUMBER
    T_ID NUMBER
    QUERY_
    select a.sname, a.sphone1, nvl(sum(b.dollar),0) ORD, nvl(sum(b.dollar2),0) ADV,
    nvl(sum(c.amt_paid),0) Paid
    from sender a, transaction b, payments c
    where a.sphone1 = b.sphone1
    and b.t_id = c.t_id(+)
    and b.paid in ('N','B')
    group by a.sname, a.sphone1
    order by 1
    HERE IS THE RESULT OF THIS QUERY:_
    SNAME SPHONE1 ORD ADV PAID
    Muhammad Atif Ishtiaq 778 889 7195 2150 635 45
    BRIEF DESCRIPTION:*
    We have sender info in SENDER table, when they place order it goes to TRANSACTION table and when they pay it goes into PAYMENTS. some times they make payments in installment of a single order. which i record them in payments with their T_ID (Transaction ID) and this is the problem what i research until now. many customers place multiple orders over a period of time but dont pay and some times pay the orders in installment. i just want to present the whole story in one single row, as i mentioned above under query result. in this example the actual ORD suppose to be $2050 instead and ADV $605. PAID is OK.
    SQL> select t_id, dollar, dollar2 from transaction where paid = 'B' and sphone1 = '778 889 7195';
    T_ID DOLLAR DOLLAR2
    18274 450
    18278 1000 500
    18263 100 30
    18265 100
    18266 100
    18268 100 25
    18269 200 50
    SQL> select t_id, amt_paid from payments
    where t_id in (select t_id from transaction
    where paid = 'B' and sphone1 = '778 889 7195')
    T_ID AMT_PAID
    18263 20
    18263 25
    AND in the end i would like to calculate balance of the columns ((ORD+ADV) - (PAID))
    Any help would be appreciated.
    best regards.
    NOTE: i am running oracle 8 and developer 6i

    try this:
    WITH TRANSACTION AS (select 18274 t_id, 450 dollar, NULL dollar2, '778 889 7195' sphone1 FROM DUAL
                         UNION ALL
                         select 18278 t_id, 1000 dollar, 500 dollar2, '778 889 7195' sphone1 FROM DUAL
                         UNION ALL
                         select 18263 t_id, 100 dollar, 30 dollar2, '778 889 7195' sphone1 FROM DUAL
                         UNION ALL
                         select 18265 t_id, 100 dollar, NULL dollar2, '778 889 7195' sphone1 FROM DUAL
                         UNION ALL
                         select 18266 t_id, 100 dollar, NULL dollar2, '778 889 7195' sphone1 FROM DUAL
                         UNION ALL
                         select 18268 t_id, 100 dollar, 25 dollar2, '778 889 7195' sphone1 FROM DUAL
                         UNION ALL
                         select 18269 t_id, 200 dollar, 50 dollar2, '778 889 7195' sphone1 FROM DUAL
         PAYMENTS AS    (select 18263 t_id, 20 amt_paid FROM DUAL
                         UNION ALL
                         select 18263 t_id, 25 amt_paid FROM DUAL
         SENDER AS      (SELECT 'Muhammad Atif Ishtiaq' SNAME, '778 889 7195' SPHONE1 FROM DUAL
    select a.sname,
           a.sphone1,
           nvl(ORD,0) ORD,
           nvl(ADV,0) ADV,
           nvl(amt_paid,0) Paid
      from sender a,
           (SELECT sphone1,
                   sum(dollar) ord,
                   sum(dollar2) adv
              from transaction b
            GROUP BY sphone1) b,
           (SELECT sphone1,
                   SUM(amt_paid) amt_paid
              FROM payments p,
                   transaction t
             where p.t_id=t.t_id
             GROUP BY sphone1) c
    where a.sphone1 = b.sphone1
    and b.sphone1=c.sphone1(+);

  • Joining three tables to get specific data set

    table1
    id
    seq
    dat
    table2
    id
    seq
    empid
    taxid
    Table3
    empid
    taxid
    I want to find out records That have same id,seq,empid having different taxid column Common to three of the tables .
    Please help me

    Hi,
    There are a lot of different things you could mean.
    Here's how to do one of them:
    SELECT       t2.id,  t2.seq,  t2.empid
    FROM       table2     t2
    JOIN       table1     t1     ON     t2.id        = t1.id
                          AND     t2.seq        = t1.seq
    JOIN       table3     t3     ON     t2.emp_id  = t3.empid
                          AND     t2.taxid   = t3.taxid
    GROUP BY  t2.id,  t2.seq,  t2.empid
    HAVING       COUNT (DISTINCT t2.taxid) > 1
    ;It would help if you posted some sample data (CREATE TABLE and INSERT statements) from all 3 tables, and the results you want from that data.

  • How to join three tables and practical difference between 10g and 11g

    I want to know with example how to outer join three different tables in Oracle.
    Also if you have any website or reference for understand syntax or performance difference between 10g and 11g then please paste a link in.thanks!!

    Hi,
    897293 wrote:
    I want to know with example how to outer join three different tables in Oracle.The 3rd table comes into the result set the same way the 2nd one did:
    FROM           table_1  t1
    LEFT OUTER JOIN      table_2  t2  ON   ...
    LEFT OUTER JOIN      table_3  t3  ON   ...The join condition(s) for t3 can reference t1, or t2, or both.
    Also if you have any website or reference for understand syntax or performance difference between 10g and 11g then please paste a link in.thanks!!The main manuals all have "What's New" sections near the beginning. For example:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/wnsql.htm#sthref5
    Hoek,
    We've missed you. Welcome back!

  • 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.

  • Row values into column....

    Hi Experts,
    Can i add column values into a single cell. Like my requirement is i want to add values of Name column in a single cell of some other table. For example if Table A contains A, B, C D names then in second table i want all these name in one cell as ABCD. I'm not able to find solution. please help me. i'm working on ODI. Any help or clue.
    Regards
    -Kirti

    Hi,
    2 suggestions:
    1) If you have a constant number of columns you could put, at an interface, so much "instances" of the datastore as the number of columns, create the join and put the necessary filter at each "instance". The mapping will be the concatenation of the column from each instance
    or
    2) Create a procedure where you have the select column_to_be_concatenated at Source TAB and an update of that at Target TAB (if necessary you can define a dynamic PL/SQL to deal with insert update!)
    Does it help you?

  • While Joining 3 tables am getting 2 rows,actual i need a single row

    Hi all,
        While joining 3 tables am getting 2 Rows, i need  1 row.
    please find my query and actual output and expected output.
    Help me out to handle this.
    select
            --MFU_D_C_INVESTOR_ID_DET,
            mfu_remove_junk(Q.CAN)                               CAN_ST,
            mfu_remove_junk(Q.INSTALLMENT_AMOUNT) AMOUNT_ST,
            mfu_remove_junk(x.Can )                                Can ,
            mfu_remove_junk(x.Amc_Code )                      Amc_Code ,
            mfu_remove_junk(x.Folio_No )                         Folio_No ,
            mfu_remove_junk(x.Order_Status )                  Order_Status ,
            mfu_remove_junk(x.User_Code )                    User_Code ,
            mfu_remove_junk(x.User_Txrn_No )               User_Txrn_No ,
            mfu_remove_junk(x.Group_Ord_No )              Group_Ord_No ,
            mfu_remove_junk(x.Ind_Txn_Ref_No )            Ind_Txn_Ref_No ,
            mfu_remove_junk(x.Pending_Txn_Ref_No )    Pending_Txn_Ref_No ,
            mfu_remove_junk(x.Appl_No )                       Appl_No ,
            mfu_remove_junk(x.Ts_Machine_Id )             Ts_Machine_Id ,
            mfu_remove_junk(x.Trxn_Date )                    Trxn_Date ,
            mfu_remove_junk(x.Trxn_Time )                    Trxn_Time ,
            mfu_remove_junk(x.Timestamp_No )             Timestamp_No ,
            mfu_remove_junk(x.Sch_Code )                   Sch_Code ,
            mfu_remove_junk(x.Reinv_Tag )                    Reinv_Tag ,
            mfu_remove_junk(x.Txn_Mode )                   Txn_Mode ,
            mfu_remove_junk(x.Trxn_Type )                   Trxn_Type ,
            mfu_remove_junk(x.Sub_Trxn_Type )           Sub_Trxn_Type ,
            mfu_remove_junk(x.Units )                          Units ,
            mfu_remove_junk(x.Amount )                      Amount ,
            mfu_remove_junk(x.All_Units_Flag )            All_Units_Flag ,
            mfu_remove_junk(x.Entity_Id )                    Entity_Id ,
            mfu_remove_junk(x.ENTITY_BRANCH_ID )  ENTITY_BRANCH_ID ,
            mfu_remove_junk(x.Location )                     Location ,
           (TO_CHAR(sysdate,'DD-MON-RRRR'))        CREATED_DATE
         From MFU_FTP_XML_FILES T
      Left Join Xmltable('/COMM_TXN_STRUCT/FILE_ROWS/FILE_ROW'
                          Passing T.Filecontent
                          Columns
    --MFU_D_C_INVESTOR_ID_DET
    Can                 Varchar2(500) Path  'INVESTOR_ID_DET/CAN',
    Amc_Code            Varchar2(500) Path  'INVESTOR_ID_DET/AMC_CODE',
    Folio_No            Varchar2(500) Path  'INVESTOR_ID_DET/FOLIO_NO',
    Order_Status        Varchar2(500) Path  'TRANSACTION_DET/ORDER_STATUS',
    User_Code           Varchar2(500) Path  'TRANSACTION_DET/USER_CODE',
    User_Txrn_No        Varchar2(500) Path  'TRANSACTION_DET/USER_TXRN_NO',
    Group_Ord_No        Varchar2(500) Path  'TRANSACTION_DET/GROUP_ORD_NO',
    Ind_Txn_Ref_No      Varchar2(500) Path  'TRANSACTION_DET/IND_TXN_REF_NO',
    Pending_Txn_Ref_No  Varchar2(500) Path  'TRANSACTION_DET/PENDING_TXN_REF_NO',
    Appl_No             Varchar2(500) Path  'TRANSACTION_DET/APPL_NO',
    Ts_Machine_Id       Varchar2(500) Path  'TRANSACTION_DET/TS_MACHINE_ID',
    Trxn_Date           Varchar2(500) Path  'TRANSACTION_DET/TRXN_DATE',
    Trxn_Time           Varchar2(500) Path  'TRANSACTION_DET/TRXN_TIME',
    Timestamp_No        Varchar2(500) Path  'TRANSACTION_DET/TIMESTAMP_NO',
    Sch_Code            Varchar2(500) Path  'TRANSACTION_DET/SCH_CODE',
    Reinv_Tag           Varchar2(500) Path  'TRANSACTION_DET/REINV_TAG',
    Txn_Mode            Varchar2(500) Path  'TRANSACTION_DET/TXN_MODE',
    Trxn_Type           Varchar2(500) Path  'TRANSACTION_DET/TRXN_TYPE',
    Sub_Trxn_Type       Varchar2(500) Path  'TRANSACTION_DET/SUB_TRXN_TYPE',
    Units               Varchar2(500) Path  'TRANSACTION_DET/UNITS',
    Amount              Varchar2(500) Path  'TRANSACTION_DET/AMOUNT',
    All_Units_Flag      Varchar2(500) Path  'TRANSACTION_DET/ALL_UNITS_FLAG',
    Entity_Id           Varchar2(500) Path  'TRANSACTION_DET/ENTITY_ID',
    ENTITY_BRANCH_ID    Varchar2(500) Path  'TRANSACTION_DET/ENTITY_BRANCH_ID',
    Location            Varchar2(500) Path  'TRANSACTION_DET/LOCATION'
    ) X
    on (1=1)
         left join XMLTABLE('/CT_SYS_STRUCT/FILE_ROWS/FILE_ROW'
                   PASSING T.FILECONTENT
                   columns
    CAN                varchar2(500)  PATH 'INVESTOR_ID_DET/CAN',
    INSTALLMENT_AMOUNT varchar2(500)  PATH 'TRANSACTION_DET/INSTALLMENT_AMOUNT'
    )Q
    on (1=1)
    Where
    TRUNC((TO_DATE(T.RETRIVED_DATE,'DD-MON-RRRR HH:MI:SS PM')))=TRUNC(SYSDATE-2)
    Order By Rownum,X.Can Asc;
    Actual O/P:
    15114LBA01  1000.00     (null)               (null)         (null)     (null)      (null)                 (null)               (null)                  
            (null)      (null)         15114LBA01    SMF         AC       MFU    40715117000    15114010001   1511401000102      
    Expected O/P:
    can_st                amount     can                 amc    order  user      trxn_no             group_ord         ind_txn_no
       15114LBA01   1000.00  
    15114LBA01    SMF 
    AC 
    MFU    40715117000    15114010001    1511401000102 

    Expected O/P:
    can_st      amount  can       amc order user trxn_no     group_ord   ind_txn_no
    15114LBA01 1000.00 15114LBA01 SMF
    AC
       MFU 40715117000 15114010001 1511401000102
    check http://docs.oracle.com/cd/E11882_01/server.112/e41084/ap_keywd001.htm#SQLRF55621
    to verify:
    with
    actual_output as
    (select '15114LBA01' can_st,1000.00 amount,null can,null amc,null order_,null user_,null trxn_no,null group_ord,null ind_txn_no from dual union all
    select null,null,'15114LBA01','SMF','AC','MFU',40715117000,15114010001,1511401000102 from dual
    select max(can_st) can_st,max(amount) amount,max(can) can,max(amc) amc,max(order_) order_,max(user_) user_,max(trxn_no) trxn_no,max(group_ord) group_ord,max(ind_txn_no) ind_txn_no
      from actual_output
    CAN_ST
    AMOUNT
    CAN
    AMC
    ORDER_
    USER_
    TRXN_NO
    GROUP_ORD
    IND_TXN_NO
    15114LBA01
    1000
    15114LBA01
    SMF
    AC
    MFU
    40715117000
    15114010001
    1511401000102
    select max(can_st) can_st,max(amount) amount,max(can) can,max(amc) amc,max(order_) order,max(user_) user,max(trxn_no) trxn_no,max(group_ord) group_ord,max(ind_txn_no) ind_txn_no
      from actual_output
    ORA-00923: FROM keyword not found where expected
    Regards
    Etbin

  • How to join three tables?

    I have used this query to join three tables but it displays an error : field vbak-vbeln is unknown.
    please help me out..
    SELECT vbak-vbeln vbak-bstnk vbap-matnr vbap-zmeng makt-maktx
    INTO CORRESPONDING FIELDs OF TABLE itab FROM vbak
    inner JOIN vbap ON vbak-vbeln eq vbap-vbeln
    inner JOIN makt ON vbap-matnr eq makt-matnr
    WHERE vbak-bstnk = s_bstnk.

    Hi mohan kumar ,
    just follow the Syntax
    SELECT FLD1 FLD2 FLD3 FLD4 FLD5 INTO CORRESPONDING FIELDS OF TABLE ITAB FROM TABLE1 INNER JOIN TABLE2 ON
    TABLE1FLD1 = TABLE2FLD1 INNER JOIN TABLE3 ON TABLE2FLD2 = TABLE3FLD2 INNER JOIN TABL4 ON  TABLE3FLD3 = TABLE4FLD3
    WHERE FLD1 = 'AA'
    Hope this may be helpful.
    Please reward points if found ok.
    Thanks and regards,
    Rajeshwar.

  • Joining three tables

    I have to join three tables but i m getting error as given below:
    Error i m getting-
    Syntax error(missing operator) in query expression 'invoice.INVOICE_NO=inv_ent_main.INVOICE_NO INNER JOIN invrate ON invrate.INVOICE_NO=inv_ent_main.INVOICE_N'.
    My Query is-
    "select inv_ent_main.EXPORTER,inv_ent_main.INVOICE_NO,inv_ent_main.INVOICE_DATE,inv_ent_main.BALE_COUNT,inv_ent_main.TOTAL_AMOUNT,inv_ent_main.BALE_COUNT,inv_ent_main.TOTAL_PIECES,inv_ent_main.TOTAL_AREA,invoice.ORDER_NO,invoice.OTHER_REF,invoice.CONSIGN1,invoice.CONSIGN2,invoice.CONSIGN3,invoice.CONSIGN4,invoice.CONSIGN5,invoice.DLV_TERMS,invoice.PAYMENT_TERMS,invoice.PRE_CARRIAGE,invoice.PR_CARRIER,invoice.DESTINATION,invoice.COUNTRY_DESTINATION,invoice.VESS_FLIGHT,invoice.PORT_LOAD,invoice.PORT_DSCH,invoice.MARK1,invoice.MARK2,invoice.CURRENCY,invoice.GOODS_DESCRIPTION,invoice.CFB,invoice.GROSS_WEIGHT,invoice.NET_WEIGHT,invoice.WOOL,invoice.COTTON
    from inv_ent_main INNER JOIN invoice ON invoice.INVOICE_NO = inv_ent_main.INVOICE_NO INNER JOIN invrate ON invrate.INVOICE_NO = inv_ent_main.INVOICE_NO";
    MCA,LUCKNOW.

    The last character in the error message has missing "O" when compare to the actual query you have posted. Please rerun it an verify or you can try the below query. You need to post DDL for all the 3 tables so that we can test.
    select
    inv_ent_main.EXPORTER,
    inv_ent_main.INVOICE_NO,
    inv_ent_main.INVOICE_DATE,
    inv_ent_main.BALE_COUNT,
    inv_ent_main.TOTAL_AMOUNT,
    inv_ent_main.BALE_COUNT,
    inv_ent_main.TOTAL_PIECES,
    inv_ent_main.TOTAL_AREA,
    invoice.ORDER_NO,
    invoice.OTHER_REF,
    invoice.CONSIGN1,
    invoice.CONSIGN2,
    invoice.CONSIGN3,
    invoice.CONSIGN4,
    invoice.CONSIGN5,
    invoice.DLV_TERMS,
    invoice.PAYMENT_TERMS,
    invoice.PRE_CARRIAGE,
    invoice.PR_CARRIER,
    invoice.DESTINATION,
    invoice.COUNTRY_DESTINATION,
    invoice.VESS_FLIGHT,
    invoice.PORT_LOAD,
    invoice.PORT_DSCH,
    invoice.MARK1,
    invoice.MARK2,
    invoice.CURRENCY,
    invoice.GOODS_DESCRIPTION,
    invoice.CFB,
    invoice.GROSS_WEIGHT,
    invoice.NET_WEIGHT,
    invoice.WOOL,
    invoice.COTTON from inv_ent_main
    INNER JOIN invoice ON invoice.INVOICE_NO = inv_ent_main.INVOICE_NO
    INNER JOIN invrate ON invrate.INVOICE_NO = inv_ent_main.INVOICE_NO
    Regards, RSingh

  • Code to Join three tables.

    Hi All,
    I am a fresher to this ABAP.
    I have an task to join three tables which doesn't take much effort. But the problem is: the tables have same columns, (name, age and city) in all the three tables.
    The layout is as shown below:
    Table 1  ( T1 )            Table 2  ( T2 )          Table 3 ( T3 )
      name | age | city      name | age | city        name | age | city    -
    Anju   21     HDD      Anju   20     BGH       Anju    21    SFF
    Julie   23     JUH       Julie   24     JUH        Julie   20     JUH
    Now, there should be a selection screen. If I enter a value for this varaible as "Anju", The output should be like:
    Col       T1        T2      T3
    Name    Anju     Anju    Anju
    Age       21        20       21
    City       HDD    BGH    SFF
    I am unable to appraoch how to solve this issue. Any pointers would be of great help.
    Thanks in advance,
    Anjum.
    Edited by: nasarat anjum on Apr 23, 2008 8:43 AM

    Hi,
    U can take three internal tables for each of ur tables T1,T2,T3. Fetch the respective table data into ur internal tables.
    Then write,
    loop at itab1.
    read table itba2 with key name eq itab1-name.
    read table itab3 with key name eq itab1-name.
    write : / name under <name heading>,
                itab1-name under <T1 heading>,
                itab2-name under <T2 heading>,
                itab3-name under <T3 heading>.
    write : / age under <age heading>,
                itab1-age under <T1 heading>,
                itab2-age under <T2 heading>,
                itab3-age under <T3 heading>.
    write : / city under <city heading>,
                itab1-city under <T1 heading>,
                itab2-city under <T2 heading>,
                itab3-city under <T3 heading>.
    <removed by moderator>
    Thanks
    Edited by: Mike Pokraka on Aug 6, 2008 8:30 AM

  • JOIN two tables and creat a new one

    dear all,
    as a newbie in Bw i have a question.
    I worked already with other etl tools (powercenter) where there are objects to join 2 tables and create a new one to create a total transforming process to load a fact table.
    In BW an INFOSET is the only thing to join 2 odssen. On this a query can be created.
    BUT HOW TO JOIN 2 TABLES (= only ODS object?) AND CREATE A NEW TABLE FOR FUTHER PROCESSING ????
    Regards,
    Herman

    hi jacobs, refer to these links particularly second one
    http://help.sap.com/saphelp_erp2004/helpdata/en/92/43ec39d0383f09e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_erp2004/helpdata/en/f1/713c3b
    35703079e10000000a114084/content.htm
    hope this clears ur doubt
    Assigning points is the way of saying thanks in sdn
    ravi

  • Compare 2 tables and insert rows missing in each table.

    I have a tough situation. I have two exact tables- one online and one offline database. I know that there are missing rows of data from each table, so I need to make a comparison of one table and insert rows that do not exist. I was thinking to try this, but it took over 3 hours to run and did not return anything:
    insert into t
    select * from t a
    where not exists (select * from [email protected] b
    where a.col1 != b.col1
    and a.col2 != b.col2
    and a.col3 != b.col3);
    and it goes on for another 7columns.
    The trouble I have is to include a date clause so that the query can be broken down into running only a few months of data comparisions at a time- the records go back 4 years to compare. Also is there a way to write this so that it will query both tables at the same time in order to speed things up- or is one table at a time the best advice? Each table has over 100 million records to compare, that's why I was hoping to use a date criteria since one column is date.
    Let me know what you advise to make this work, I hope I was on the right track.

    Not sure if the MINUS operator will perform better with your data set but;
    SQL> create table t1 (some_id number, some_date date)
    Table created.
    SQL> create table t2 (some_id number, some_date date)
    Table created.
    SQL> insert into t1 values (1, trunc(sysdate))
    1 row created.
    SQL> insert into t1 values (2, trunc(sysdate-5))
    1 row created.
    SQL> insert into t1 values (4, trunc(sysdate-90))
    1 row created.
    SQL> insert into t2 values (1, trunc(sysdate))
    1 row created.
    SQL> insert into t2 values (3, trunc(sysdate-10))
    1 row created.
    SQL> insert into t2 values (5, trunc(sysdate-100))
    1 row created.
    SQL> select * from t1
       SOME_ID SOME_DAT
             1 07-07-30
             2 07-07-25
             4 07-05-01
    3 rows selected.
    SQL> select * from t2
       SOME_ID SOME_DAT
             1 07-07-30
             3 07-07-20
             5 07-04-21
    3 rows selected.
    SQL> insert into t1 (
       select some_id, some_date from t2 where some_date between sysdate-50 and sysdate
       minus
       select some_id, some_date from t1 where some_date between sysdate-50 and sysdate)
    1 row created.
    SQL> insert into t2 (
       select some_id, some_date from t1 where some_date between sysdate-50 and sysdate
       minus
       select some_id, some_date from t2 where some_date between sysdate-50 and sysdate)
    1 row created.
    SQL> select * from t1
       SOME_ID SOME_DAT
             1 07-07-30
             2 07-07-25
             4 07-05-01
             3 07-07-20
    4 rows selected.
    SQL> select * from t2
       SOME_ID SOME_DAT
             1 07-07-30
             3 07-07-20
             5 07-04-21
             2 07-07-25
    4 rows selected.

  • After getting 4G with AT&T I am unable to join my network and get the error message: Unable to  join the network "Jude". How do I fix this? Thank you

    After getting 4G with AT&T I am unable to join my network and get the error message: Unable to  join the network "Jude". How do I fix this? Thank yo

    Try power-cycling your wireless router (unplg for 30 seconds, plug back in).  Here's a longer list of troubleshooting steps: http://support.apple.com/kb/TS1398.

  • Trying to insert a table and getting a "While executing objectTag in Table.htm, a JavaScript error o

    trying to insert a table and getting a "While executing objectTag in Table.htm, a JavaScript error occurred." message appears.  how do I fix this?

    Try this Technote
    http://kb2.adobe.com/cps/405/kb405604.html
    Try step 4 here
    http://kb2.adobe.com/cps/405/kb405604.html#main_dat

  • Query to join 2 tables by interval of value

    Hi all
    I need your help in creating a query to join 2 tables by interval of values.
    The thing i want to d ois like this: i have 2 tables the first one containing list of serial number and the secon is containing interval of serial number (startnumber and end number) and other information like the user creating the serial number.
    I want to list all serial numbers from the first table and the user creating each serial number from the second one if the serial number is between each interval of the second table.
    here is an example>
    SQL> create table test1 (code varchar2(1), serial number);
    Table created.
    SQL> create table test2 (requester varchar2(10),startno number, endno number);
    Table created.
    SQL> insert into test1 values('A',1);
    1 row created.
    SQL> insert into test1 values('B',3);
    1 row created.
    SQL> insert into test1 values('C',8);
    1 row created.
    SQL> insert into test1 values('D',12);
    1 row created.
    SQL> insert into test1 values('E',20);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> insert into test2 values('TATA',1,5);
    1 row created.
    SQL> insert into test2 values('TOTO',6,10);
    1 row created.
    SQL> commit;
    Commit complete.
    The result i want to get are:
    TESt1.CODE     TEST2.REQUESTER
    A          TATA
    B          TATA
    C          TOTO
    D          null
    E          null

    Use outer join:
    select  code,
            requester
      from  test1,
            test2
      where serial between startno(+) and endno(+)
      order by code
    C REQUESTER
    A TATA
    B TATA
    C TOTO
    D
    E
    SQL> SY.

Maybe you are looking for

  • Creation of System Alias between Portal and E Sourcing System

    Hi Team, I would like to create a System Alias between SAP Portal 7.4 and E Sourcing System 10.0. I would like to know during the creation of System Object which template i need to take (is it http System or R/3 System using Load Balancing). If it is

  • Navigate to another iView in Visual Composer

    Sorry for the reposting I am trying to configure navigation from one iView to another. I have going through many tutorials but to no avail. The result of the steps below should be that the ”source” iView is shown. When the submit button is clicked th

  • The History Eraser in Inaction

    I have had the need to do a specific erasure and can't seem to do it. I have a file with a b&w conversion layer applied. I come back a few days later and decide that a portion of the image needs attention, so I open the b&w layer and make a few chang

  • Cant Open Oracle Apps 11i Forms after installing latest JRE

    We are currently on Oracle Apps 11.5.10.2. I had to install latest JRE 1.6 Update23 to be able to work on BI Publisher Templates and now I can't open any of the Oracle Forms under eBusiness Suite. IE just crashes, doesnt show any message on JInitiato

  • Excel 2013 Power Map Preview Issue

    Hi- I used power map to make some great data visualizations-it looked amazing and the interactivity was fantastic.  Now, when I open up my spreadsheet, or try to create a new one, the land forms are missing.  It looks like the world was flooded.  My