Selecting data from three tables

Hi Every one...
I have three tables, Tbl_FlData, Tbl_Flsubdata,Tbl_OutDirection_Dtl, in these tables the common columns are OUTNO, OUTYEAR. When I am trying to pull data from two tables Tbl_Fldata, Tbl_OutDirection_Dtl by using below query I am getting exact output what i want.
SELECT Tbl_FLData.OUTNO, Tbl_FLData.OUTHDATE,Tbl_OutDirection_Dtl.OTSERNO FROM Tbl_FLData INNER JOIN Tbl_OutDirection_Dtl ON Tbl_FLData.OUTYEAR = Tbl_OutDirection_Dtl.OUTYEAR AND Tbl_FLData.OUTNO = Tbl_OutDirection_Dtl.OUTNO.
But the problem is, when I am trying to pull a column from Tbl_FlSubdata.Remarks the out put is coming but the records are duplicating.
The fields of the tables are
Tbl_FlData: OUTNO, OUTYEAR, OUTHDATE, SUBJECT,USERDEPTCODE, FDEPTCODE, SENDHDATE, REPLYINDAYS, EXPECTEDHDATE, UD_UID
Tbl_FLSUBDATA: OUTNO, OUTYEAR, OTSSERNO, SEQNO, EMPCODE, SEQHDATE, REMARKS, UD_UID
Tbl_OutDirectionDtl : OUTNO, OUTYEAR, OTSERNO, DI_Code, REPLYHDATA, INNO, INHDATE, IN_UD_UID, IN_REMARKS.
Please help me in this issue.

Hi,
Try something like this.
SELECT distinct Tbl_FLData.OUTNO,
Tbl_FLData.OUTHDATE,
Tbl_FLSUBDATA.OTSSERNO
Tbl_OutDirection_Dtl.OTSERNO
FROM Tbl_FLData, Tbl_FLSUBDATA, Tbl_OutDirection_Dtl
where Tbl_FLSUBDATA.OUTNO = Tbl_FLData.OUTNO(+)
and Tbl_OutDirection_Dtl.OUTNO = Tbl_FLData.OUTNO(+)
order by Tbl_FLData.OUTNO;
considering Tbl_FLData as the master table. If there are any other unique fields like "out_no" include it a way as above after "where" with a (+) join and see if you still get duplicates.

Similar Messages

  • Select data from three tables

    Hi,
    Tables :PROJ-JEST-TJ30T     Target Field:TXT04
    PROJ-PSPNR--> PROJ-OBJNR =JEST-OBJNR  + JEST-INACT = «blank»
    JEST-STAT = (TJ30T-ISTAT = E* (we have to take only E*)+ TJ30T-SPRAS = EN) -->TJ30T-TXT04
    We can have some status to display here, please concatenate and separate them by a coma.
    can you give me suggestion to fill that requirement?
    Regards
    Subbu

    sth like this:
        SELECT
               P~pspnr...
                                                                                    INTO   CORRESPONDING FIELDS OF  itab
                    FROM ( proj AS p INNER JOIN jest AS J
                           ON POBJNR = JOBJNR )
                    join TJ30T as t
                          on T~ISTAT =  J-TSTAT
               WHERE T~spras = 'EN'
                 and      T~ISTAT  like 'E%'.....
    A.

  • Error while selecting date from external table

    Hello all,
    I am getting the follwing error while selecting data from external table. Any idea why?
    SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
      2        SE_CUST_ID NUMBER(38),
      3        SE_TRAN_AMT_LCY FLOAT(126),
      4        SE_REVERSAL_MARKER VARCHAR2(255))
      5  ORGANIZATION EXTERNAL (
      6    TYPE ORACLE_LOADER
      7    DEFAULT DIRECTORY ext_tables
      8    ACCESS PARAMETERS (
      9      RECORDS DELIMITED BY NEWLINE
    10      FIELDS TERMINATED BY ','
    11      MISSING FIELD VALUES ARE NULL
    12      (
    13        country_code      CHAR(5),
    14        country_name      CHAR(50),
    15        country_language  CHAR(50)
    16      )
    17    )
    18    LOCATION ('SE2.csv')
    19  )
    20  PARALLEL 5
    21  REJECT LIMIT UNLIMITED;
    Table created.
    SQL> select * from se2_ext;
    SQL> select count(*) from se2_ext;
    select count(*) from se2_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04043: table column not found in external source: SE_REF_NO
    ORA-06512: at "SYS.ORACLE_LOADER", line 19

    It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
    HTH -- Mark D Powell --

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • How to select data from a table by passing document number from another tab

    How to select data from a table by passing document number from another table.
    for eg:-
    I want to display name, adres, region from ADRC table
    by using field delivery document number
    Kind Regards,
    Shanbagavalli.S

    Hi Shanbagavalli,
    There are multiple solutions to this questions a few i will try to answer and then you can take the best required for your requirements.
    **Consider that you have a Internal table having document number from other table..
    SELECT NAME ADRES REGION FROM ADRC
           INTO IT_ADRC
           FOR ALL ENTRIES IN IT_DOC
           WHERE DOCUMENT_NO = IT_DOC-DOCUMENT_NO.
    **Consider that you have 1 document number then
    SELECT NAME ADRES REGION FROM ADRC
         INTO IT_ADRC
         WHERE DOCUMENT_NO = W_DOCUMENT_NO.
    Hope this solves your problem.
    Regards,
    Kunjal

  • Select data from two tables...!

    HI Experts...!
    i m a beginner user and i want to select data from two tables proj and prps.....using joins.....and internal tables i have written a code...
    SELECT prps~pspnr
           prps~objnr
           prps~psphi
           proj~ernam
           proj~erdat
           proj~pspnr
    INTO  table itab   -
    itab is internal table
    FROM prps inner join proj
    WHERE pspnr in p_no and prpspsphi = projpspnr.
    but there is error in from clause ..please help me....
    Advance thanx....

    Hi,
    check the sample code bellow above two reply will solve out your problem but one more extra line in your code pointed out bellow.
    TABLES: prps, proj.
    TYPES:  BEGIN OF ty_test,
            pspnr LIKE prps-pspnr,
            objnr LIKE prps-objnr,
            psphi LIKE prps-psphi,
            ernam LIKE proj-ernam,
            erdat LIKE proj-erdat,
            END OF ty_test.
    DATA: itab TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
    SELECT-OPTIONS: p_no FOR prps-pspnr.
    SELECT  prps~pspnr
            prps~objnr
            prps~psphi
            proj~ernam
            proj~erdat
    *        proj~pspnr " No need for this you have selected this in
    *     the first line because it is commone so you only need to select from any one
            INTO TABLE itab
    FROM prps INNER JOIN proj ON ( prps~pspnr = proj~pspnr  )
    WHERE prps~pspnr IN p_no.
    Best Regards,
    Faisal
    Edited by: Rob Burbank on Dec 24, 2009 12:24 PM

  • Selecting data from two tables

    I am trying to select data from two tables.  The only problem that I am running into, is that i am only seeing results from my 'uploads' table.  there is also a record in documents where user = 1 that should show up.  here is my sql:
    $userIDNum = 1;
    $sql="Select *
    from uploads, documents
    WHERE uploads.user = documents.user AND uploads.user = $userIDNum
    ORDER BY uploads.title ASC, documents.title ASC";

    You'll need to explain a little more about your data and what you are trying to accomplish. Your current sql will select all columns from both the uploads and documents tables but only rows where the user id in both tables match, AND the user id equals 1. Is that not what you are seeing? Where's the code that outputs the results?

  • How to select data from cluster table

    hi experts,
                   I have a report which picks data from bseg (cluster table ) for a month report it is taking around 4 minutes to process.I feel it is not good when take the report after some months.
    how to select data from these table???how to declare itab for these cluster tables????can we include any search condition or any other kind of internal table???
    please advice.
    mani

    Hi Manikandan,
    The following code may be helpful to understand how to select the data from cluster table.
    Types: Begin of ty_kna1,
    Kunnr type kna1-kunnr,
    adrnr type kna1-adrnr,
    end of ty_kna1,
    begin of ty_bseg,
    belnr type bseg-belnr,
    kunnr type bseg-kunnr,
    end of ty_bseg,
    begin of ty_final,
    belnr type bseg-belnr,
    kunnr type kna1-kunnr,
    adrnr type kna1-adrnr,
    end of ty_final.
    Data: it_kna1 type table of ty_kna1,
    wa_kna1 type ty_kna1,
    it_bseg type table of ty_bseg,
    wa_bseg type ty_bseg,
    it_final type table of ty_final,
    wa_final type ty_final.
    Select kunnr adrnr from kna1 into table it_kna1 where....
    if sy-subrc = 0.
    select belnr kunnr into table it_bseg for all entries in it_kna1 where kunnr = it_kna1-kunnr.
    endif.
    sort it_kna1 by kunnr.
    Loop at it_bseg into wa_bseg.
    move wa_bseg-belnr to wa_final-belnr.
    read table it_kna1 into wa_kna1 with kunnr = wa_bseg-kunnr binary search.
    if sy-subrc = 0.
    move: wa_kna1-kunnr to wa_final-kunnr,
    wa_kna1-belnr to wa_final-belnr.
    endif.
    append wa_final to it_final.
    clear wa_final.
    endloop.
    Loop at it_final into wa_final.
    write: / wa_final-belnr, wa_final-kunnr, wa_final-adrnr.
    endloop.
    Reward if useful.
    Thankyou,
    Regards.

  • Select data from a table and a view: field with same content and different type

    hi all,
    I need data from a table hrp1001 and a view V_USR_NAME. What they have in common are the content of the fields SOBID and BNAME .
    It will be easier if those fields add a same type but they dont.
    Any suggestions for a workaround?
    Thanks

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • Selecting data from external table

    Hi there
    I was wondering if somebody could assist me. When I try to select data from an external table, no data is displayed, and in my log file I receive the following error:
    KUP-04026: field too long for datatype. Please find attached my external table script.
    CREATE TABLE DEMO_FILE_EXT
    MACODE               NUMBER(7),
    MANO                    NUMBER(7),
    DEPNO                    VARCHAR2(2 BYTE),
    DEPTYPE                    NUMBER(5),
    STARTDATE               NUMBER(8),
    ENDDATE               NUMBER(8),
    OPTIONSTART               NUMBER(8),
    BENEFITSTART     NUMBER(8),
    STARTSUSPEND          NUMBER(8),
    ENDSUSPEND          NUMBER(8),
    INITIALS          VARCHAR2(5 BYTE),
    FIRSTNAME          VARCHAR2(20 BYTE),
    SURNAME                    VARCHAR2(25 BYTE),
    STR1                    VARCHAR2(30 BYTE),
    STR2                    VARCHAR2(30 BYTE),
    STR3                    VARCHAR2(30 BYTE),
    STR4                         VARCHAR2(30 BYTE),
    SCODE                    VARCHAR2(6 BYTE),
    POS1                    VARCHAR2(30 BYTE),
    POS2                    VARCHAR2(30 BYTE),
    POS3                    VARCHAR2(30 BYTE),
    POS4                    VARCHAR2(30 BYTE),
    PCODE                    VARCHAR2(6 BYTE),
    TELH                    VARCHAR2(10 BYTE),
    TELW                    VARCHAR2(10 BYTE),
    TELC                    VARCHAR2(10 BYTE),
    IDNUMBER          VARCHAR2(13 BYTE),
    DOB                NUMBER(8),
    GENDER               VARCHAR2(1 BYTE),
    EMPLOYER_CODE               VARCHAR2(10 BYTE),
    EMPLOYER_NAME               VARCHAR2(900 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY DEMO_FILES
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY newline
         BADFILE 'Tinusb.txt'
         DISCARDFILE 'Tinusd.txt'
         LOGFILE 'Tinusl.txt'
    SKIP 1
    FIELDS TERMINATED BY '|'
              MISSING FIELD VALUES ARE NULL
         (MACODE,
         MANO,
         DEPNO,
         DEPTYPE,
         STARTDATE,
         ENDDATE,
         OPTIONSTART,
         BENEFITSTART,
         STARTSUSPEND,
         ENDSUSPEND,
         INITIALS,
         FIRSTNAME,
         SURNAME,
         STR1,
         STR2,
         STR3,
         STR4,
         SCODE,
         POS1,
         POS2,
         POS3,
         POS4,
         PCODE,
         TELH,
         TELW,
         TELC,
         IDNUMBER,
         DOB,
         GENDER,
         EMPLOYER_CODE,
         EMPLOYER_NAME
    LOCATION (DEMO_FILES:'Test1.txt')
    REJECT LIMIT UNLIMITED
    LOGGING
    NOCACHE
    NOPARALLEL;
    I have the correct privileges on the directory, but the error seems to be on the EMPLOYER_NAME field. The file I try to upload is in pipe-delimited format. The last field in the file does not have a pipe-delimiter at the end. Can this be the problem? Must I go and look for any trailing spaces? Can I specify in the external table script how many characters I need for the employer_name field? We receive this file from an external company
    Thank you very much for the help
    Ferdie

    common mistake, you gave the field sizes in the
    column listing of the table, but not in the file
    definition. oracle does not apply one to the other.
    in the file defintion section, give explict field
    sizes.Hi shoblock
    Sorry for only coming back to you now, thank you for your help, I had to give the explicit field size for the last column (employer name).
    Thank you once again!!
    Ferdie

  • Select data from database tables with high performance

    hi all,
    how to select data from different database tables with high performance.
    im using for all entries instead of inner joins, even though burden on data base tables is going very high ( 90 % in se30)
    hw to increase the performance.
    kindly, reply.
    thnks

    Also Check you are not using open sql much like distict order by group by , use abap techniques on internal table to acive the same.
    also Dont use select endselect.
    if possible use up to n rows claus....
    taht will limit the data base hits.
    also dont run select in siode any loops.
    i guess these are some of the trics oyu can use to avoid frequent DATA BASE HITS AND ABVOID THE DATA BASE LAOD.

  • How Select data from four tables

    Hi Sdners,
    How select data from four or more tables please give me any suggestion. iam learner please help me
    Advance wishes
    sreenu
    Moderator Message: I've already locked 2 threads of yours. Please read the Rules of Engagement of this forum and abide by it.
    Edited by: kishan P on Sep 5, 2010 9:12 PM

    I think there was a sample of using CURSOR in the XSQL docs.Check section:
    Using the CURSOR Operator for Nested Rowsets
    null

  • Selecting Data from CE1* tables

    Hi guys!
    Why is it that when I select data from our CE1* table, it is faster to select
    PERIO = '2007.007'
    than to select
    GJAHR = '2007' and PERDE = '007'?
    Thanks!

    > Hi,
    >
    > Are you executing the query and Se16 in same client?
    > if you are then the reason can be that some of the
    > fields are case sensitive and you are passing data in
    > all Caps.
    >
    > Also you can check by accepting the data through
    > PARAMTERS rather than hard coding the stuff, the
    > reason can be that there are some converison routines
    > that convert the data into a format that is required
    > to fetch the data which may be Se16 does and your
    > hardcoding does not.
    >
    > Regards,
    > Sesh
    I found out now. It is because actual data for PALEDGER is '010' not '10'.
    Thanks anyway!

  • How to select data from AZure table storage without row key and partition key

    Hi 
    I need to select a data from azure table storage without rowkey and partition key. how  in azure storage emulator click query it display all data from that table. 
    thanks 
    rajesh 

    Hi rajesh,
    It seems that you didn't click query data using storage emulator. But I recommend you could use the azure server explore in your VS to view your data and query data. Please see this document (http://msdn.microsoft.com/en-us/library/azure/ff683677.aspx).
    And base on my experience, you may need input the command on Azure storage emulator, such as this page(http://msdn.microsoft.com/en-us/library/azure/gg433005.aspx).
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Procedure to insert data into table by selecting data from another table

    Hi all,
    I have to create a procedure where i have to select the data from one table and insert it into another table. Any help on this. And i have to update the 2nd table also when ever new records got inserted in the 1st table then.
    Regards

    Hi, you can try something like:
    CREATE [OR REPLACE] PROCEDURE procedure_name
    IS
    BEGIN
    INSERT INTO TABLE1
    VALUES (SELECT * FROM TABLE2);
    END;
    For the other part you may create a trigger on the first table AFTER INSERT to insert the values in the second table too.

Maybe you are looking for

  • Problem with decimal numbers..

    hi i posted the other day with a problem I had. I thought it was all sorted but I have just realised that there is another problem. I have the following code for an applet: import java.applet.*; import java.awt.*; import java.awt.event.*; public clas

  • Do you have an installer for Acrobat 6.0 Standard for Mac???

    Please help me!  Can you send me an installer for Acrobat 6.0 Standard for Mac???  The Acrobat Customer Service "help" says this is the only way I can get my Acrobat going again.  It won't bother YOUR installer to share it with me.....and I must use

  • Add command with SAP SAP Tables & Clusters.

    Hi All, One of my customer is using the SAP integration kit and the document states that we can have a Add Command option in Crystal Reports XI against the SAP tables. So in Crystal Reports can we create an ADD COMMAND option against the SAP tables?

  • Encore CS5 crashes on startup

    I've tried uninstalling and reinstalling with no success. Help please.

  • Configure tomcat

    hi, while I am starting server I got yhis error.. Out of environment space The BASEDIR environment variable is not defined correctly This environment variable is needed to run this program Out of environment space Out of environment space Using CATAL