Need to join the data, of different tables

I have some data in 3 tables, Table 1 has all the names say, table1 has column Name with data as A,B,C,D,E. Table 2 has columns Name,Logins_T2,Entering_T2. Same way table2 has columns Name,Logins_T3,entering_T3. Now, I want to join these 3 tables, i want
all the names of table1 and the columns logins_T2,entering_T2,logins_T3,entering_T3.
How can I join them, i tried by using left join but it is not giving the correct result, can anyone help me do this

I think this is what you are trying to do. Please try this.CREATE TABLE Test1 (Name varchar(20), Col2 varchar(20))
CREATE TABLE Test2 (logins_T2 varchar(20), entering_T2 varchar(20))
CREATE TABLE Test3 (logins_T3 varchar(20), entering_T3 varchar(20))
INSERT INTO Test1(Name, Col2) VALUES('A', 'test1_A'), ('B', 'test1_B'), ('C', 'test1_C'), ('D', 'test1_D')
INSERT INTO Test2(logins_T2, entering_T2) VALUES('A', 'test2_A'), ('C', 'test2_C')
INSERT INTO Test3(logins_T3, entering_T3) VALUES('B', 'test3_B'), ('C', 'test3_C')
SELECT * FROM Test1 t1
LEFT OUTER JOIN Test2 t2 ON t1.Name = t2.logins_T2
LEFT OUTER JOIN Test3 t3 ON t1.Name = t3.logins_T3
Prakash Machiraju
Please vote if you find this posting was helpful or Mark it as answered.
I am doing this way,
SELECT t1.name,t2.logins_T2,enteringS_T2,t3.Logins_T3,t3.entering_T3 FROM Test1 t1
LEFT OUTER JOIN Test2 t2 ON t1.Name = t2.Name
LEFT OUTER JOIN Test3 t3 ON t1.Name = t3.Name
Logins and enterings are the integers and Table 2 and 3 also has column 'Name'.

Similar Messages

  • Need to save the data in mutiple tables

    Dear Experts,
    I need to insert the data ,which is accepted from the user at runtime using table control and also generate automatic number when clicked on the save button the data should be in the database as well.
    I am new to module pool, your help is reqd. The user will be awarded ample points if answered correctly.
    regards,
    Rachel

    Hi Rachel,
    For automatic number generation you need to create number range object using tcode SNRO and then use the foolowing logic.
    *&      Form  GET_NEXT_NUMBER
          text
    -->  p1        text
    <--  p2        text
    FORM get_next_number .
      DATA: w_quant   LIKE inri-quantity,    "dummy
            w_code    LIKE inri-returncode.  "returncode
    To lock the number range object
      CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
        EXPORTING
          object           = 'ZNUM'
        EXCEPTIONS
          foreign_lock     = 1
          object_not_found = 2
          system_failure   = 3
          OTHERS           = 4.
    To raise the exception to the corresponding exception of
    'NUMBER_RANGE_ENQUEUE'
      IF sy-subrc NE 0.
        MESSAGE e368(00) WITH text-006."'Object is not found'
      ENDIF.                         "IF sy-subrc NE 0
    To get the next number from the object
      CALL FUNCTION 'NUMBER_GET_NEXT'
        EXPORTING
          nr_range_nr             = 'Z2'
          object                  = 'ZNUM'
          toyear                  = '2008'
        IMPORTING
          number                  = l_lbc_next
          quantity                = w_quant
          returncode              = w_code
        EXCEPTIONS
          interval_not_found      = 1
          number_range_not_intern = 2
          object_not_found        = 3
          quantity_is_0           = 4
          quantity_is_not_1       = 5
          interval_overflow       = 6
          buffer_overflow         = 7
          OTHERS                  = 8.
      IF sy-subrc <> 0.
        CLEAR ok_code.
        MESSAGE e368(00) WITH text-006."'Object is not found'
      ENDIF.               "IF sy-subrc <> 0
    To unlock the number range object
      CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
        EXPORTING
          object           = 'ZNUM'
        EXCEPTIONS
          object_not_found = 1
          OTHERS           = 2.
      IF sy-subrc NE 0.
        CLEAR ok_code.
        MESSAGE e368(00) WITH text-006."'Object is not found'
      ENDIF.              "IF sy-subrc NE 0
    ENDFORM.                    " GET_NEXT_NUMBER
    And for table control logic
    see the below link.
    Table control of Module Pool Program
    Regards,
    Raju

  • Joining the data from two Tables

    I create a table with six months date from Jan to Jun. Another table with July trough Sept.
    Now I want one table in which I am going to at the end of the year have all 2007 fiscal data.
    I do not want to restore them ever back to the components. How do I do this?

    If I understand you correctly, I think you merely want to enlarge the first table enough to accommodate the data from the second table. Then select the cells in the second table and copy and paste them into the newly created space in the first table. Ask if you need more detail instructions on how to do this.

  • How to delete the data in a table using function

    hi all,
    i need to delete the data in a table using four parameters in a function,
    the parameters are passed through shell script.
    How to write the function
    Thanks

    >
    But the only thing is that such function cannot be used in SQL.
    >
    Perhaps you weren't including the use of autonomous transactions?
    CREATE OR REPLACE FUNCTION remove_emp (employee_id NUMBER) RETURN NUMBER AS
    PRAGMA AUTONOMOUS_TRANSACTION;
    tot_emps NUMBER;
    BEGIN
    SELECT COUNT(*) INTO TOT_EMPS FROM EMP3;
    DELETE FROM emp3
    WHERE empno = employee_id;
    COMMIT;
    tot_emps := tot_emps - 1;
    RETURN TOT_EMPS;
    END;
    SQL> SELECT REMOVE_EMP(7499) FROM DUAL;
    REMOVE_EMP(7499)
                  12
    SQL> SELECT REMOVE_EMP(7521) FROM DUAL;
    REMOVE_EMP(7521)
                  11
    SQL> SELECT REMOVE_EMP(7566) FROM DUAL;
    REMOVE_EMP(7566)
                  10
    SQL>

  • How to dynamically display the data from a table base on row selection of another table in ADF

    Hi ,
    I have a requirement in ADF. I need to change the data of a table  based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.
                                                                                         For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.
    My method is following
        public void onrowselection(SelectionEvent selectionEvent) {
            RichTable richTable = (RichTable)selectionEvent.getSource();
                            CollectionModel tableModel = (CollectionModel)richTable.getValue();
                            JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
                            Object selectedRowData = richTable.getSelectedRowData();
                            JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
                    oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
                    Number pallet = newVal.bigDecimalValue();
                    System.out.println("Selected values " + pallet);
            BindingContext bindingctx = BindingContext.getCurrent();
                          BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
                          DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
                  DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
                          ViewObject vo =dciter.getViewObject();
                          vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
                          vo.executeQuery();
    It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log
    "Definition DepartmentId of type Variable is not found in EmployeesView1."
    I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.
    Thanks
    Nilesh

    Note quite sure why you simply wont create a viewlink for the viewobject the tables are based on..
    The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.
    However, if both tables are on the same page; using your hack about;
    On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.
    I would bind table two to a RichTable component:
    RichTable t2;
    public void onrowselection(SelectionEvent selectionEvent) {
            RichTable richTable = (RichTable)selectionEvent.getSource();
                            CollectionModel tableModel = (CollectionModel)richTable.getValue();
                            JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
                            Object selectedRowData = richTable.getSelectedRowData();
                            JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
                    oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
                    Number pallet = newVal.bigDecimalValue();
                    System.out.println("Selected values " + pallet);
                   refreshTable2(pallet);
            BindingContext bindingctx = BindingContext.getCurrent();
                          BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
                          DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
                  DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
                          ViewObject vo =dciter.getViewObject();
                          vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
                          vo.executeQuery();
    private void refreshTable2(Number pallet){
    RichTable x=getT2();
    CollectionModel cm=(CollectionModel)x.getValue();
    JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();
    BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
    DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
    DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");
    ViewObject vo =dciter.getViewObject();
    ViewCriteriaManager vcm=vo.getViewCriteriaManager();
    ViewCriteria vc=vcm.getViewCriteria("listById");
    vo.applyViewCriteria(vc);
    vo.setNamedWhereClauseParam("DepartmentId",pallet);
    vo.executeQuery();
    AdfFacesContext.getCurrentInstance().addPartialTarget(getT2());

  • How to display multiple data from different table in one table? please help

    Hi
    I got sun java studio creator 2(the separate installation not the one in the net beans)....
    My question is about displaying data that have been taken from the database.... I know how to display data in a table(just click on the table "bind data" )... but my question is that:
    when i want to use a sql statement that taken the data from different table...
    how can i display that data in the table(that will be shown in the web) ??? when i click bind data on the table i can only select one table i can't select more than one....
    Note:
    1) i'm using the rowset for displaying the data in the table, since the sql statement is depending on a condition(i.e. select a from b where c= ? )...
    2) i mean by different table is that( i.e. select a from table1,table2 )..
    thanks in advance...

    Hi,
    937440 wrote:
    Hi every one, this is my first post in this portal. Welcome to the forum!
    Be sure to read the forum FAQ {message:id=9360002}
    I want display the details of emp table.. for that I am using this SQL statement.
    select * from emp where mgr=nvl(:mgr,mgr);
    when I give the input as 7698 it is displaying the corresponding records... and also when I won't give any input then it is displaying all the records except the mgr with null values.
    1)I want to display all the records when I won't give any input including nulls
    2)I want to display all the records who's mgr is null
    Is there any way to incorporate to include all these in a single query..It's a little unclear what you're asking.
    The following query always includes rows where mgr is NULL, and when the bind variable :mgr is NULL, it displays all rows:
    SELECT  *
    FROM     emp
    WHERE     LNNVL (mgr != :mgr)
    ;That is, when :mgr = 7698, it displays 6 rows, and when :mgr is NULL it displays 14 rows (assuming you're using the Oracle-supplied scott.emp table).
    The following query includes rows where mgr is NULL only when the bind variable :mgr is NULL, in which case it displays all rows:
    SELECT     *
    FROM     emp
    WHERE     :mgr     = mgr
    OR       :mgr       IS NULL
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL it displays 14 rows.
    The following query includes rows where mgr is NULL only when the bind variab;e :mgr is NULL, in which case it displays only the rows where mgr is NULL. That is, it treats NULL as a value:
    SELECT     *
    FROM     emp
    WHERE     DECODE ( mgr
                , :mgr, 'OK'
                )     = 'OK'
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL, it displays 1 row.

  • Need to change the date of joining of employee

    Hi All,
    I have gone through some threads similar to this subject an also tried to do changes from PA41 but i am facing some problems during the procedure.
    We have transferred some employees to sap system with their original date of joining and payroll was run from some other date for those employees. So i need to change the date of joining of those employees.
    For example : Below is the line items of one employee from table infotype 0.
    End date Start date Changed on
    22.02.2009 19.02.2007 19.02.2009
    31.03.2009 23.02.2009 19.02.2009
    31.12.2009 01.04.2009 14.10.2009
    31.12.9999 01.01.2010 21.01.2010
    Payroll was run from Feb-09 onwards and i want put date of joining for this employee as 23.02.2009.
    I want to know which date i need to change??...When i am trying to change the first start date i.e. 19.02.2007 to my desired start date, but it is not allowing me to do that as end date is smaller.
    Please tell me how would i change the joining date of employee as 23.02.2009 ?.
    Thanks.

    Try this
    22.02.2009 19.02.2007
    31.03.2009 23.02.2009
    31.12.2009 01.04.2009
    31.12.9999 01.01.2010   take this record form PA30  IT0000 Over View (Shif +  F8)  Copy that record and change the Start date
    as 2302.2010  so  another record will be created
    22.02.2010    01.01.2010
    31.12.9999    23.02.2010
    Just try and let me know

  • I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    I want to use the SQL Toolkit of NI and SQL Server as my databasis on a server. Do I need to install a client in each computer I want to handle the data into SQL tables or I need only a ODBC driver?

    You only need the ODBC driver on each computer. If you are distributing the SQL Toolkit app as an executable and do not install the whole toolkit on each computer, you'll need the SQL Toolkit support files. This is about a dozen files. You can get the list at http://digital.ni.com/public.nsf/websearch/b814be005f9da9258625658700550c75?OpenDocument.

  • How can i join the header and item table to fetch the data

    hi experts,
                   i have a doubt in using inner join or for all entries, for fetching the data from the item table mseg, by taking the doc.no from mkpf. Plz sort out the difference, what happens, if i use the both statements for fetching data

    Hi,
    Both has same functionality.
    but if u are using FAE, u ahev to check for the
    ~intial condition of the source table,
    ~ duplicate entries, if any
    Inner join will fetch the data from all the join tables at once. FAE will fetch the date from a table first then use that data to fetch data from subsequent table.
    say in ur case, if u r using FAE,
    1.select from mkpf.
    2.select from mseg fae in I_MKPF.
    first try using JOIN. if it is taking lots of time, then try FAE.
    regards,
    madhu

  • Need solu to Append the data frm different files..Element 'Rec' not expecte

    i need solution to append the data coming from different files.
    sample file is of format
    Header Records
    Data Records
    i need to append the data coming from files to single file which consist of single header and data records from all the four files.
    Using assign activity to append the Data Record. but not able to force the data to write in the target location
    Facing following error..
    Record in the below error is data records. i can view all the appended data put variable.but facing following error Element 'Record' not expected.
    <Record>
    <RecType>1</RecType>
    <SSAppsID>ICD </SSAppsID>
    <TSAppsID>NPS </TSAppsID>
    <FileType>CUSTOMER</FileType>
    <SeqNo>0030</SeqNo>
    <CusNum>50902 </CusNum>
    <CSAppID>ICONS </CSAppID>
    <CusName>YTL Communications Sdn Bhd </CusName>
    <OldIDCardNum/>
    <NewIdentyCardNum/>
    <PassPortNum/>
    <BusinessRegNum/>
    <Police_armyPerNum/>
    <SEGCode>W20</SEGCode>
    <SecCode/>
    <NewSegCode/>
    <IcareMAsterAccNum/>
    </Record>
    </Record>
    </Root-Element>
    </part>
    </PutFilesToTarget_Put_InputVariable>
    </input>
    <fault>
    <bpelFault>
    <faultType>0</faultType>
    <bindingFault>
    <part name="summary">
    <summary>Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Put_InboxNew' failed due to: Translation Error. Translation Error. Error while translating message to native format. Please make sure that the payload for the outbound interaction conforms to the schema. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution. </summary>
    </part>
    <part name="detail">
    <detail>Element 'Record' not expected.</detail>
    </part>
    <part name="code">
    <code>null</code>
    </part>
    </bindingFault>
    </bpelFault>
    </fault>
    <faultType>
    <message>0</message>
    </faultType>
    </messages>

    ya i am reading the data and writing the data with the same format..
    but i need to append data from different files..eliminating the header from second file..
    i am invoking the write adapter out of the while loop..
    this seems some problem while writing..its looking for data records still..

  • Need to extract the data from the CRM table : SCAPPTSEG

    Hi BW Experts,
    I want to extract the Data from CRM Table "SCAPPTSEG" to BW. The dates are stored in UTC Format.So for getting the date in CET format, we have used the Function Module "IB_CONVERT_FROM_TIMESTAMP".
    I want to create a datasource for extracting the data from "SCAPPTSEG" table and i need to use the function module for getting the date in CET Format.
    Can i achieve this action through Generic Extraction.
    please provide me the steps to achieve this.
    Thanks,
    Shahina.A

    not answered

  • How to delete the data from partition table

    Hi all,
    Am very new to partition concepts in oracle..
    here my question is how to delete the data from partition table.
    is the below query will work ?
    delete from table1 partition (P_2008_1212)
    we have define range partition ...
    or help me how to delete the data from partition table.
    Thanks
    Sree

    874823 wrote:
    delete from table1 partition (P_2008_1212)This approach is wrong - as Andre pointed, this is not how partition tables should be used.
    Oracle supports different structures for data and indexes. A table can be a hash table or index organised table. It can have B+tree index. It can have bitmap indexes. It can be partitioned. Etc.
    How the table implements its structure is a physical design consideration.
    Application code should only deal with the logical data structure. How that data structure is physically implemented has no bearing on application. Does your application need to know what the indexes are and the names of the indexes,in order to use a table? Obviously not. So why then does your application need to know that the table is partitioned?
    When your application code starts referring directly to physical partitions, it needs to know HOW the table is partitioned. It needs to know WHAT partitions to use. It needs to know the names of the partitions. Etc.
    And why? All this means is increased complexity in application code as this code now needs to know and understand the physical data structure. This app code is now more complex, has more moving parts, will have more bugs, and will be more complex to maintain.
    Oracle can take an app SQL and it can determine (based on the predicates of the SQL), which partitions to use and not use for executing that SQL. All done totally transparently. The app does not need to know that the table is even partitioned.
    This is a crucial concept to understand and get right.

  • Query the data between two tables

    Need help for query the data between two tables
    Table 1: Time sheet
    P.ID      P.Name EmpID HoursSpend DateTime
    c12234  Test      25        4                06/12/2013
    c12234  Test      25        7                06/13/2013
    c12234  Test      25        8                06/15/2013
    c12234  Test      5          3                06/21/2013
    c12234  Test      2          5                07/15/2013
    c12234  Test      25        4                07/21/2013
    Table 2: cost table
    EmpID  FromDate       ToDate         Rate
    25         05/01/2013    06/30/2013    250
    2         04/01/2013    05/31/2013      150
    25         07/01/2013     09/30/2013    300 
    Output
    P.ID      P.Name EmpID HoursSpend DateTime       Rate   Total (HoursSond x Rate)
    c12234  Test      25        4                06/12/2013    250     1000 (4*250)
    c12234  Test      25        7                06/13/2013    250      1750
    c12234  Test      25        8                06/15/2013    250      
    2000
    c12234  Test      25        4              07/21/2013     300       
    1200
    c12234  Test      2          5              07/15/2013    150          
    750
    ===========================================     
    Total                           28                                                 
    6700
    ============================================
    Here EmpID =2 don't have rate in the cost table on july month should be pick from last entry from cost table.

    Hi Gopal,
    According to your description, it seems that the output needn’t include the row when EmpID=2. Because the DateTime for it in Table1 doesn’t included between FromDate column and ToDate column. After testing the issue in my environment, we can refer to the
    query like below to achieve your requirement:
    SELECT time.*,cost.EmpID,cost.Rate,(time.HoursSpend * cost.Rate)as [Total (HoursSond x Rate)]
    FROM [Time sheet] as time
    INNER JOIN
    [cost table]as cost
    ON time.EmpID = cost.EmpID
    AND time.DateTime BETWEEN cost.FromDate AND cost.ToDate
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Fetch data from different tables print them is assigned places

    Hi Friends,
    I have designed one SMART-Form (Receipt).
    I need to fetch data from different tables and the data must be print in assigned places. Please help me how to achieve this requirement. Thanks for your help.
    Best regards,
    Manju.
    Edited by: Alvaro Tejada Galindo on Feb 12, 2008 10:20 AM

    U're right.
    When it creates a smartform it needs to decide when the main data have to be extracted:
    - or in driver program
    - or in smartforms
    The difference can be in the performance, because the program can select the data only once, the smartforms needs to extract them everytime it's called.
    I prefer to use a complex structure for the smartform interface as so all data I need are in only one structure, the problem is the complex structure is harder to be managed.
    Max

  • Fastest way to import the data for big tables

    Hi friends,
    I have recently joined a billing product set up team for TELECOM giant.As part of the setup process /initial testing we need to put huge data (nearly 1.5 billion records/~200 GB size of data) in some tables. Currently i am using impdp for importing .It takes a lot of time (nearly >9 hours for loading this data).
    I have tried the below ways to import the data(All these tables are partitioned):
    1. Normal impdp (single thread i.e. parallel=1): This one takes a lot of time (>24 hours).
    2. Normal impdp but partition-wise .This one is completed in relatively less amout of time compared to the 1st method.
    3. Drop drop the indexes ,do inset append from another schema in same instance which has the data and then recreate the indexes ( total process takes ~9 hours)
    My questions to all:
    1.Is there any other way/trick in the book which I can try to put the data in less amount of time
    2.What i have observed that even if I give parallel=8 or any number ,sometimes parallel workers are spawned and sometimes not. Can someone educate me why ?
    3.How can i come to know (before running the impdp ) that my parallel clause is going to spawn the parallel workers or not. I have searched on this subject but no success as to how I will come to know this.
    I dont know what strategy to follow ,because this is a involved and repetitive task for me. Due to the above task I am not able to concentrate on other DBA tasks due to this which come to me.
    Cheers,
    Kunwar

    assuming you have a table with 3 indexes, then create a script for each index (reblace index_name_n with your index name) and start them at the same time, after the import of the table is completed
    DUMPFILE=<DUMPFILE> or NETWORK_LINK=<DBLINK>
    DIRECTORY=DATA_PUMP_DIR
    LOGFILE=<IMP_INDEX_NAME_n>
    CONTENT=ALL
    PARALLEL=1
    JOB_NAME=IMP_<INDEX_NAME_n>
    INCLUDE=TABLE_EXPORT/TABLE/INDEX:"IN('<INDEX_NAME_n>')"
    TABLES=<SCHEMA>.<TABLE>change following settings during import:
    increase pga_aggregate_target
    increase db_writer_processes
    db_block_checking=false
    db_block_checksum=false
    set undo and temp ts to autoextend
    set noarchivelogmode
    create 4GB redo logs
    hth

Maybe you are looking for