Getting data from three tables

I have 3 tables
SQL> select * from t1;
C1
d1
d2
SQL> select * from t2;
C1 C2
d1 g1
d1 wf1
d2 g2
d2 wf2
SQL> select * from t3;
C2 C3
wf1 open
wf1 closed
wf1 closed
wf1 cancelled
wf2 closed
wf2 cancelled
wf2 closed
I would like to join rows from t1 and t2 for no t3.c3='open' ie the result I want is:
C1 C2
d2 wf2
d2 g2
Thanks

Am afraid, if you look at it logically from your table structure, you can see you only have one data open. So the result you expected to get as stated is wrong.
I believe this is the correct answer
SQL> select a.c1, b.c2, c.c3 from t1 a, t2 b, t3 c where a.c1 = b.c1 and b.c2 = c.c2 and c.c3 = 'ope
n' order by 1;
C1 C2 C3
d1 wf1 open
Cube60

Similar Messages

  • How to get data from three tables (A,B,C) having one to many relation between A and B .and having one to many reation between b and c

    i have  three tables A,B,C.  there is one to many relation between A and B. and one to many relation existed between table b and c . how will get data from these three tables

    check if this helps:
    select * --you can always frame your column set
    from tableA a
    left join tableB b on a.aid=b.aid
    left join tableC c on c.bid=b.bid
    This is just a general query. However, we can help you a lot more, if you can post the DDL + sample data and required output.
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to get data from a table in a condition between twomonth

    hai friends
    I have a query that is i want to get data from a table based on a condition between two months in a format of char column
    Ex
    I have a column called from_month in the format of 'mon/yyyy'(already converted from date')
    then the second column is to_month in the same format 'mon/yyyy'
    now i wiil select from_month and to_month like
    from month jan/2009
    to month mar/2010
    how to use between of two months in the format of char.Please tell me how to get two different month between data.

    Hi,
    This may be of help.
    Remember Pointless has made a point ;) (worth millions)
    If possible , DO NOT store dates as strings or numbers.Let dates be dates.
    WITH dat AS
    (SELECT ' THIS IS JAN' x,to_char(to_date('01-JAN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS FEB' x,to_char(to_date('01-FEB-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAR' x,to_char(to_date('01-MAR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS APR' x,to_char(to_date('01-APR-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS MAY' x,to_char(to_date('01-MAY-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUN' x,to_char(to_date('01-JUN-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS JUL' x,to_char(to_date('01-JUL-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS AUG' x,to_char(to_date('01-AUG-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS SEP' x,to_char(to_date('01-SEP-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS OCT' x,to_char(to_date('01-OCT-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual UNION
    SELECT ' THIS IS NOV' x,to_char(to_date('01-NOV-2009','DD-MON-YYYY'),'mon/yyyy') y FROM dual)
    SELECT * FROM dat
    WHERE to_date(y,'mon/yyyy') BETWEEN to_date('01 jan 2009','dd mon yyyy') AND to_date('01 mar 2009','dd mon yyyy')Cheers!!!
    Bhushan

  • How to get data from COSP table, field HRKFT as the key to data from PM?

    Dear ladies and gentlemen!
    I need to get data from COSP table, field HRKFT as the key to data from PM tables (AFKO and AUFK).
    The problem is that it is a key field to the COSP, and all non-key fields as an alternative to HRKFT are not suitable for this task.
    All this is necessary for the extractor, which loads the data from the R \ 3 systems in the BW-system. I need to perform SELECT from a table COSP and maybe also JOIN, most likely between tables COSP and AUFK.
    What should I do in this case?
    Thank you very much in advance!

    From information on help.sap.com I've made a conclusion that one of possible solutions in theory is to modify standard extractor PM_OM_OPA_1 in order to make HRKFT field available for work, because by default it is hidden by SAP and not available for use as a key field.
    Of course, it's not a very good solution, but for now I know no other way to solve this problem.
    Maybe someone knows better ways? In this case I will be very grateful for any help!
    Moderator: You'd better post it on BI forums

  • How to get data from large table (more than 9 million rows) by EJB?

    I have a giant table, it has more than 9 million rows.
    I want to use ejb finders method to get data from this table but always get not enough memory error or time out error,
    Can anyone give me solutions?
    Thx

    Your problem may be that you are simply trying to load so many objects (found by your finder) that you are exceeding available memory. For example if each object is 100 bytes and you try to load 1,000,000 objects thats 100Mb of memory gone.
    You could try increasing the amount of memory available to OC4J with the appropriate argument on the command line (or in the 10gAS console). For example to make 1Gb available to OC4J you would add the argument:
    -Xmx1000m
    Of course you need have this available as hard memory on your server or you will incur serious swapping.
    Chris

  • Jdbc getting data from multiple tables

    hi guys
    how can i get data from multiple tables in MSAccess
    please help

    >
    here is code thata i want to do
    i have 3 tables in my MSAccess databace
    Stud_O which consist name,surname fields
    Stud_I consist address,tel
    Stud_E department,faculty fields
    Based on this I would guess that you are missing a key field. There is no way to connect the tables.
    I make the class to insert data to the tables. But
    cant do getting datas from this tables.
    can anybody help me in making query
    and method that displays reultset strings to the
    textBoxes
    A select ...
    select name,surname from Stud_O. Use the executeQuery() method.

  • Getting data from 7 tables

    I am converting a servlet based application to struts framework.I have a screen which gets data from 7 tables.I cannot use a stored procedure so has to manage using SQL queries.I thought i will query each table and set it to my struts form.The screen has lot of drop down boxes .
    I have heard of composite design pattern .Please let me know the best way to query the tables.Here are the queries.
    Select a.proj_id , a.proj_nm
    From stn_proj_et a, stn_proj b
    Where a.proj_id = b.proj_id
    And a.sftwr_id = 24
    And b.stn_id = 56602;
    Select round(utm_x,3) utm_x, round(utm_y,3) utm_y, stn_id
    From stn_loc_hist
    Where stn_id ='56602'
    And cur_use_cd = 1
    select data_tp_cd
    from data_coll_summ
    where stn_id ='56002'
    And rownum < 2;
    select lat_no,long_no,pnt_loc_dsc,srce_id,mthd_dtrmn_cd,ctrl_dtm_cd
    from stn_et
    where stn_id = '56002';
    select
    distinct sjr_utils.getcatalogvalue(mthd_dtrmn_cd)
    from stn_et;
    select
    distinct sjr_utils.getcatalogvalue(ctrl_dtm_cd)
    from stn_et;
    select distinct PROJ_NM from stn_proj_et where sftwr_id=24;
    Select a.stn_alias_nm stn_alias_nm, b.alias_orgn_nm alias_orgn_nm
    From stn_alias_nm a, alias_orgn_et b
    Where a.alias_orgn_id = b.alias_orgn_id
    And b.alias_orgn_tp = 0
    And stn_id = '56002';

    adithiananya wrote:
    I am converting a servlet based application to struts framework.How well do you know Struts?
    I have a screen which gets data from 7 tables.I cannot use a stored procedure so has to manage using SQL queries.I thought i will query each table and set it to my struts form.The screen has lot of drop down boxes .You don't need a stored procedure to query a database.
    I have heard of composite design pattern .This ain't it.
    Please let me know the best way to query the tables.Here are the queries.
    Select a.proj_id , a.proj_nm
    From stn_proj_et a, stn_proj b
    Where a.proj_id = b.proj_id
    And a.sftwr_id = 24
    And b.stn_id = 56602;What are those hard-wired magic numbers in the WHERE clause?
    >
    Select round(utm_x,3) utm_x, round(utm_y,3) utm_y, stn_id
    From stn_loc_hist
    Where stn_id ='56602'
    And cur_use_cd = 1What are those hard-wired magic numbers in the WHERE clause?
    >
    select data_tp_cd
    from data_coll_summ
    where stn_id ='56002'
    And rownum < 2;What are those hard-wired magic numbers in the WHERE clause?
    >
    select lat_no,long_no,pnt_loc_dsc,srce_id,mthd_dtrmn_cd,ctrl_dtm_cd
    from stn_et
    where stn_id = '56002';
    select
    distinct sjr_utils.getcatalogvalue(mthd_dtrmn_cd)
    from stn_et;
    select
    distinct sjr_utils.getcatalogvalue(ctrl_dtm_cd)
    from stn_et;
    select distinct PROJ_NM from stn_proj_et where sftwr_id=24;What are those hard-wired magic numbers in the WHERE clause?
    Select a.stn_alias_nm stn_alias_nm, b.alias_orgn_nm alias_orgn_nm
    From stn_alias_nm a, alias_orgn_et b
    Where a.alias_orgn_id = b.alias_orgn_id
    And b.alias_orgn_tp = 0
    And stn_id = '56002';What are those hard-wired magic numbers in the WHERE clause?
    Do you really want to execute different requests given input from the users? (e.g., enter a value in a text box and see the drop down list boxes change)
    %

  • JSON - get data from Oracle table

    Hi all,
    I hope it is correct thread...
    My need is to get data from oracle table using JSON and show output at html table. I'm very new to JSON (got some experience in PL/SQL and basic html knowledge). Could someone direct me to manual or give me simple example?

    JSON is a way to format data, not a way to fetch data. Call it an alternative to XML.
    Are you perhaps talking about doing an ajax request to fetch data?

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

  • Getting data from 3 tables

    Hi all,
    Iam working with a jdbc-to-jdbc scenario.In this I am having 3 tables on source side called t1 , t2 & t3. On target side I am having 2 tables called tb1 & tb2. Now I have to retrieve data from 3 tables and insert into 2 tables using one type of condition with t1 & t2 and another condition with t1 & t3 . Can I do this with single scenario, If yes How can I?
    Can anybody  pleaseeee.......
    Thanks & Regards,
    Radhika.

    Hi Varun,
    My tables are UTOIP, UTTMS, UTCT.And the corresponding fields are as follows...
    UTOIP ---> OPGUI
    UTTMS -- >  MSGUI
    UTCT --->  CTGUI, CTSTS, CTECMA
    The condition to retrieve data from UTOIP and UTCT is < UTOIP.OPGUI = UTCT.CTGUI and UTCT.CTSTS = 'N' and UTCT.CTECMA = 'OPSOIP' >
    The condition to retrieve data from UTTMS and UTCT is < UTTMS.MSGUI = UTCT.CTGUI and UTCT.CTSTS = 'N' and UTCT.CTECMA = 'OPSOCLM' >
    Can u please tell me how to get the seperate data of both tables using these conditions....
    Thanks & Regards,
    Radhika.

  • How to get data from multiple tables

    Hello Everyone,
    I need to read data from a few tables (VBAK, VBAP, VBUK, VBUP etc.) because I'd like to get all open Sales Orders. I've tried to use RFC_READ_TABLE but it looks like it can read only 1 table at a time. I've tried to read data from individual table and then join them but it didn't work out very well because I got about 1.5 millions records from just the VBUP table. So anyone knows if there is any function that I can use to join those tables and just get the records I need?
    Any help would be highly appreciated.

    Hi Nhan,
    Thank you for your reply.
    Do I have to be a SAP developer to create BAPI on SAP? What kind of access rights do I need?
    I've tired to use other BAPIs such as BAPI_SalesOrder_GetList and it doesn't work for me because I don't have all customer numbers and I need to get all un-shipped orders for all customers.
    I've read a post on the internet brieftly menitoned that we can create a table to store information about the tables we want to join and then call the RFC_READ_TABLE function. Do you know if that is possible?
    Is there any other way you can think of?

  • OC4J - How to get data from large table (more than 9 million rows) by EJB?

    SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS
    O I use Jdeveloper to create EJB that has finder methods to get data from a big table (more S than 9 million rows). Deploy is OK but when run client program I always get timeout
    O error or not enough memory error,
    S Can any one help me?
    O urgent
    SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS

    Your problem may be that you are simply trying to load so many objects (found by your finder) that you are exceeding available memory. For example if each object is 100 bytes and you try to load 1,000,000 objects thats 100Mb of memory gone.
    You could try increasing the amount of memory available to OC4J with the appropriate argument on the command line (or in the 10gAS console). For example to make 1Gb available to OC4J you would add the argument:
    -Xmx1000m
    Of course you need have this available as hard memory on your server or you will incur serious swapping.
    Chris

  • Getting data from REGUP table

    Hi All,
    I am working on a report where i need to get the data from few tables and get it displayed, in the requirement I need to get some data from REGUP based on the vendor and then I am trying to retrieve the information from PAYR table such as check #, check date. So far I have tried selecting the information from REGUP using the vendor number entered by the user and then I am doing a select on PAYR to get the other information for all the entries in my REGUP internal table. Using a simple select statement is taking lot of time and I am having performance issues, can you please suggest any better approach? I understand REGUP is a huge table.
    Thanks,
    Raj

    Hi Raja,
    RUGUH is Payment header table and REGUP is payment item table.
    If your basic requirement is to pick data from PAYR table only then why don't you write query as below,
    Select
    laufd
    laufi
    hktid
    hbkid
    from reguh
    into table it_data_reguh
    where ZBUKR = 'ZTC'
    AND    lifnr in s_lifnr.
    sort it_data_reguH.
    select chect
               bancd
    for all entries in it_data_reguH
    into table it_data_payr
    where ZBUKR = 'ZTC'
    AND hbkid = it_data_reguH-hbkid
    AND HKTID = it_data_reguH-hKTid
    AND laufd = it_data_reguH-laufd
    and  laufi =  it_data_reguH-laufi.
    After doing above you can pick entries from REGUP if required as REGUP contains item details against the paymnt header details IN REGUH, you will also find all key fields of REGUP table from REGUH table hence your performance will definitely get improve.
    Hope it will help you.
    Regards,
    Umang Mehta

  • ALV OOps report- getting data from two tables and adding issue

    Hi,
    This is sales employee performance report.
    I need to select all the fields from two tables based on user input ie VKorg, sales employee .
    There is one field callled " Net sales"in both the tables.
    Based on sales employee number, i need to add that net sales which i get from two tables.
    I need to generate single report.
    Can you give some inputs reg. the select query.
    My idea is select all the data from both tables using join statement.
    Thanks

    Hi,
    I have written like this:
    select * from S002 as a join S006 as b
        into table ME->SS002_RAW[]
        where vkorg in me->select_parameters->SO_VKORG[] = vkorg in me->select_parameters->SO_VKORG[]
              and ZZSLSEMP01 in me->select_parameters->SO_so_empl[] = ZZSLSEMP02 in me->select_parameters->SO_so_empl[].
    when i do like that,
    I am getting error
    Incorrect structure of FROM clause . . . .     
    If you give some idea on this
    Edited by: Raja on Apr 22, 2009 11:19 AM

  • Select statement failed to get data from transparent table

    Hi Experts,
                      Please let me know why my select statement is failing to get data form transparent table REGUH. My code query is as below:
    SELECT * FROM REGUH WHERE
                              LAUFD = RUN_DATE AND
                              LAUFI = ID AND
                              LIFNR = P0009-PERNR AND
                              RZAWE = 'C'.
      MOVE REGUH-RWBTR TO CASH.
          CASH = CASH * -1.
      ENDSELECT.
    REGUH table has data for the given query but it is not retreiving the data.Please let me know what is the problem with the query
    because of which it is not fetching the data.The same query is working fine in Developement but fails in production may be because one new patch is updated.please help asap.

    Hi Ankita,
    Why you are going for select *
    Try This...
    SELECT SINGLE RWBTR
                  INTO v_RWBTR
                  WHERE LAUFD = RUN_DATE
                   AND  LAUFI = ID
                   AND  LIFNR = P0009-PERNR
                   AND  RZAWE = 'C'.
    MOVE v_RWBTR TO CASH.
    CASH = CASH * -1.
    Regards,
    Raj.

Maybe you are looking for

  • How to use testdb?(answered for two options,thanks)

    No info found for this tool. Last edited by lilsirecho (2008-01-23 04:24:45)

  • Creating an endpoint for a brokered web service on PI 7.1

    Hi    We recently upgraded to PI 7.1 EHP1 ( SP5 ) from XI 3.0 SP23. In XI 3.0, we had a scenario - in which - using a SOAP sender channel  and outbound message interface on XI , a web service definition (WSDL ) file was provided to a consuming applic

  • CN60 - Change document report

    Hi All, For some reason history is not always captured for all events on CN60. When I confirm an activity I put on the Actual date, reflecting on a milestone. However when I go to CN60 to do an audit check, sometimes the new value column does not ref

  • Re: RLC

    Hi frnds, I designed RLC circuit using labview. Everything is working fine but still I couldn't see any waveform in the XY graph. kindly help m to fix this issue. For your reference i attach my RLC vi. please have a look and let me you if there is an

  • Can't update Premiere Pro CC

    Hi, Premiere Pro CC won't update any more, returning error U44M1P7 Windows 7 x64 is fully up to date, as is the CC desktop app. Please help!