Querying from 3 tables

i want to display the records for this day. the thing is that the data comes from 3 different tables.
the query contains the ff columns:
date         tableA
entryid      tableA
audittype   tableA
name        tableB
shift          tableA
package    tableC
machine    tableA
tableB has
badge
name
tableC has
id
packageplease help
thanks

Try this:
with tableA as
(select to_date('02-16-07','mm-dd-yy') date1, 1 entryid, 'prod' audittype, 1 badge, 'N' shift, 1 pkgid, 'Mach1' machine from dual
  union all
  select to_date('02-16-2007','mm-dd-yy') date1, 2 entryid, 'prod' audittype, 2 badge, 'N' shift, 2 pkgid, 'Mach1' machine from dual),
     tableB as
(select 1 badge, 'Amy' name1 from dual
  union all
  select 2 badge, 'Zach' name1 from dual),
     tableC as
(select 1 pkgid, 'Pkg1' package1 from dual
  union all
  select 2 pkgid, 'Pkg2' package1 from dual)
select a.date1, a.Entryid, a.Audittype, b.name1 Name, a.Shift, c.package1 Pkg, a.Machine
from tableA a
join tableB b
on  a.badge = b.badge
join tableC c
on  a.Pkgid = c.pkgid;

Similar Messages

  • Ad Hoc Query from table PPDIT

    Hi,
    I'm creating an ad hoc query to retrieve data from table PPDIT by filtering the transaction key. This is to get a list of amounts posted to the technical accounts(Transaction key HRA). However, the query output and the output from table PPDIT through SE16 are different. It seems like the query only picks up transaction key HRF. Anyone with any ideas why?

    Hi,
    Than you add the additional field from extras option.
    click on extras tab.
    From there add table add field add structure.
    If you want to add a field write the name of the field and continue.
    suppose the field is matnr.
    Long text = material number
    header = material number
    and in like reference = mara-matnr.
    tablename-field name.
    let me know if this helps you.
    Regrds,
    Nikhil.

  • J2IUN Mismatch with query from table J_1IPART2

    Hi experts,
    If I run the TCODE J2IUN there is a marked difference for the RG23C register BED, AED, Cess, and HCess values that have been taken from table J_1IPART2 for the same period. What could be the cause for these differences and why did they occur or do I have to take addtional records from another table also. Well I am considering the Opening balances also.
    Please can you help me regarding this.
    Regards
    Yao Chhang

    You will have to first trace the difference. In the next step, go through J2IUN in debug mode with Abaper & check from where all the data is being picked. Next check whether all the data pick point are considered in Query.
    Regards,
    Rajesh Banka
    Reward suitable points.

  • Help in query from table

    Hi,
    I am having a strange issue,
    i have a table containing the following amgst others
    rec_time sys_date
    7:00 04/08/2010
    8:00 04/08/2010
    9:00 05/08/2010
    I need to query this table and return the max(rec_time) for all sys_date = sysdate
    its not working if i do the following
    select max(rec_time) from table
    where sys_date = sysdate;

    hello,
    this is my table structure for hourly_sales
      ID                 NUMBER,
      PRODUCT            VARCHAR2(25 BYTE)          NOT NULL,
      GAME_ID            NUMBER                     NOT NULL,
      SYS_DATE           DATE                       NOT NULL,
      CONFIRMED          CHAR(1 BYTE)               DEFAULT 'N',
      ACT_AMT            NUMBER                     NOT NULL,
      CUMM_AMT           NUMBER                     NOT NULL,
      COUNT_SALES        NUMBER                     NOT NULL,
      CREATED_BY         VARCHAR2(25 BYTE),
      CREATION_DATE      DATE,
      LAST_UPDATED_BY    VARCHAR2(25 BYTE),
      LAST_UPDATED_DATE  DATE,
      REC_TIME           VARCHAR2(25 BYTE)          NOT NULL,
      ORDER_ID           NUMBERI have created a small application in APEX that has an LOV for rec_time from 7.00 to 22.00. this is just an indication to the times that values are being entered.
    Now those geezers were making mistakes and the reason why i wanted my query was to enable them to roll-back on a button click
    delete from hourly_sales
    where rec_time = max(rec_time)
    and trunc(sys_date) = trunc(sysdate);but when i was querying it was not returning any values.

  • How to Query from table and insert into another table.

    Hi
    I am using the following query in VO and all the columns are attached to EO ( table name emp_temp)
    select a.npw_number, a.person_id,b.assignment_id,a.title,a.last_name,a.first_name,a.date_of_birth,a.sex,
    b.organization_name,b.organization_id,b.job_id,b.job_name,b.position_id,b.position_name,b.supervisor_id,
    b.supervisor_name,b.location_id,b.effective_start_date,b.effective_end_date
    from per_all_people_f a,per_assignments_v b
    where a.person_id=b.person_id
    and a.npw_number=:1
    I can query the data in screen. I need into insert the data into the emp_temp.
    I don't know how to do this . Please help me.
    Thanks
    Subra

    You can create a VO based on EO on emp_temp table.....
    And u have attached a Different VO on the page... Right...
    Now what u can do is....once u click on apply....
    u can set the each attributes of EO based VO explicitly via code, from the values of second VO.... and then commit.....
    Perhaps this might help...

  • How to query from tables?

    Hi!
    I have two table, and I want to execute a query statement from them. How to do this?
    Thanks so much!

    Hi,
    If you go to otn.oracle.com/products/jdev you find tutorials and Oracle By Example (OBE) instructions.
    These get you started
    Frank

  • Fetch Insert / Update Query From Table Trigger

    Hi everyone !,
    I have a situation, is there any way where I can get insert/update query by before-insert / after insert trigger when a user inserts/updates any row in the table.
    Plz....help me....champs.....
    Regards,
    Naushad

    That was a nice thing but it works only on some oracle 9i with DML statements.
    On database versions 9.2.0.1 to 9.2.0.6 ora_sql_text works and returns the calling text for dml triggers, where as starting from 9.2.0.7 the behavior has changed and returns NULL.
    Cause
    This issue had surfaced from 9.2.0.7.0 patchset. After discussions in Bug 4171597 which was closed as a duplicate of Bug 4230721 it was concluded that it was the expected behavior i.e ORA_SQL_TXT should return null when dml triggers are used.
    ORA_SQL_TXT is a "System defined event attribute" and is supposed to work only with "System triggers". This is also what the Documentation says - "Application Developers Guide : Fundamentals(9.2)
    Chapter 16 Working with System events".
    Bye Alessandro

  • Query from table a and insert to table b

    Hi,
    I would like to create an attendance page to record student's attendance on a particular dates.
    I have 2 tables - students and attendance tables; in which attendance table will consist of PK from students table and date.
    How do I create a form that display all the students record in a page with checkbox and date column; and when user check the boxes and click save; it will insert record into attendance table? Thanks!
    Layout similar to the below:
    Date: 1/1/2010 (user input)
    Name: Attend
    student 1 (checkbox)
    student 2 (checkbox)
    student 3 (checkbox)
    student 4 (checkbox)
    .....

    Hi Aaron,
    For this you can do the following
    1. Create a Tabular Form on The STUDENT table, i.e. the table you are using as a Fecth only table
    2. Make the ApplyMRU and ApplyDRD process conditions Never so they will not be executed
    3. Write your own custom process to write the checked rows into Attendence Table.
    In the process you will have to refer to the checkbox f+nn+ item using APEX_APPLICATION.G_F+nn+ array and write from similar arrays for the other tabular form items
    You will find useful code snippets in the Apex Help , Advanc3ed Tutorials as well as here http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html#MANUAL
    Regards,

  • Query to return list of all missing primary key ids from table T1

    I found this query online that returns a start and stop for a range of all missing primary key id values from table T1. However i want to rewrite this query to return a whole list of all the missing primary key ids and not a start and stop range. any help plz?
    select strt, stp
    from (select m.id + 1 as strt,
    (select min(id) - 1 from T1 x where x.id > m.id) as stp
    from T1 m left outer join T1 r on m.id = r.id - 1 where r.id is null)x where stp is not null

    with t as
              select  1 as id from dual union all
              select  2 as id from dual union all
              select  3 as id from dual union all
              select  5 as id from dual union all
              select  8 as id from dual union all
              select 10 as id from dual union all
              select 11 as id from dual union all
              select 20 as id from dual
    select  id_start + level missing_id
      from  (
             select  id id_start,
                     nullif(lead(id) over(order by id) - 1, id) id_end
               from  t
      start with id_end is not null
      connect by prior id_start = id_start
             and prior dbms_random.random is not null
             and level <= id_end - id_start
    MISSING_ID
             4
             6
             7
             9
            12
            13
            14
            15
            16
            17
            18
    MISSING_ID
            19
    12 rows selected.Or:
    with t as
              select  1 as id from dual union all
              select  2 as id from dual union all
              select  3 as id from dual union all
              select  5 as id from dual union all
              select  8 as id from dual union all
              select 10 as id from dual union all
              select 11 as id from dual union all
              select 20 as id from dual
    select  id_start + level - 1 missing_id
       from  (
              select  min(id) id_start,
                      max(id) id_end
                from  t
       connect by level <= id_end - id_start
    minus
    select  id
       from  t
    MISSING_ID
             4
             6
             7
             9
            12
            13
            14
            15
            16
            17
            18
    MISSING_ID
            19
    12 rows selected.SY.

  • SAP Query - Additional field that collects information from table RESB

    Hello gurus. I have a question.
    I want to create a SAP Query that shows me the stock level of a list of materials, and also show me the total quantity of order reservations in an additional field.
    I created an InfoSet with table MARD, which is the one that holds the Stock information in a plant. Then I created an additional field which would read information from table RESB, the table that holds order reservations per material.
    So I wrote this piece of code:
    SELECT * FROM RESB
    WHERE MATNR EQ MARD-MATNR and
           WERKS EQ MARD-WERKS.
    ENDSELECT.
    if ( sy-dbcnt NE '0').
          MOVE RESB-BDMNG to ZQTY.
    ELSE.
          MOVE '' to ZQTY.
    ENDIF.
    This works fine. However, this is currently just catching the first record in table RESB that matches my condition.
    What I would like is to collect every instance of RESB-BDMNG and add them to field "ZQTY", have it loop in RESB until it finishes finding every record that match the MATNR and WERKS. With this I could get the total number of order reservations that this material has in that table.
    Could someone share some coding that would help me achieve this?

    Yes! That did it. That's what I needed to do. Thank you so much.
    While I'm at it, let me ask you a related question.
    When I execute the query, in the first records of the query where there's no value from RESB to transfer, the value of field ZQTY appears empty. Once it finds the first record in RESB and it populates ZQTY with a value, then the rest of the records with no hit get the proper value of 0.
    Do you know why the first records in the query appear empty and not with a 0? Is there anything I should add to the coding to fix this?

  • Query from oracle to MySql using dblink fetch all the rows in MySql table

    Hello,
    I am using Heterogeneous connectivity between oracle 10204 to Mysql database.
    I have a database link in the oracle side .
    I am query a table in MySql that have 10 million rows.
    Its doesnt matter if i am running :
    select * from "CDR_Accounts"@mysql where "id"=7675405;
    or
    select * from "CDR_Accounts"@mysql ;
    There is an index on the id column.
    Yet, it seems that the Mysql is feteching all the rows from the table , all the data is transfering to oracle over the dblink , and only after that the requested rows are get back to the client.
    The /etc/odbcinst.ini file is as follow:
    [odbcprd:oracle@odbc /software/oracle]$ cat /etc/odbcinst.ini
    [myodbc3]
    Description             = Mysql connector to mysql version 3.5
    Driver          = /software/oracle/MysqlOdbc/3.52/lib/libmyodbc3-3.51.25.so
    Driver64                = /usr/lib
    Setup           = /software/oracle/MysqlOdbc/3.52/lib/libmyodbc3S-3.51.25.so
    Setup64         = /usr/lib
    UsageCount              = 1
    CPTimeout               = 3600
    CPReuse         = Please advice
    Thanks

    When using a gateway it is always possible that a where clause is not sent to the remote database. This is called post processing and depends on several factors like the used ODBC driver, the columns and its data types but also if you specify certain functions in the where clause.
    The fastest way to see if post processing happens is in Oracle 11g the explain plan for a query. In 10g the plan does not always match the statement sent to the foreign database. Here it would be better to enable gateway tracing and setting the trace level to ON. This will log the statements sent to the foreign database and you can compare what statement was sent with the statement you've tried to execute.

  • Dbms_xmlgen.newcontext query from multiple tables and ||

    I have two questions
    How do I get a dbms_xmlgen.context to query from multiple tables? I have been able to make it work with using one table only, but not with multiple tables.
    And how to get the || (concat) to work within my query for my output to an xml file?
    Here is my current query:
    create or replace function get_xml return clob is
    result clob;
    qryctx dbms_xmlgen.ctxHandle;
    SELECT DBMS_XMLGEN.getxml('select prefix, suffix, fiscal_yr
    FROM rcv.recv_accessions ra
    where ra.prefix = 8 and ra.fiscal_yr = 11')xml into result FROM dual;
    result := DBMS_XMLGEN.getXML(qryCtx);
    This is what I desire:
    SELECT DBMS_XMLGEN.getxml('select ra.prefix||'-'|| ra.suffix||'-'|| ra.fiscal_yr accession, ss.date_in, st.test
    FROM rcv.recv_accessions ra, ser.sero_samples ss, ser.sero_tests st
    where ra.prefix = 8 and ra.fiscal_yr = 11 and ss.raid = ra.id and st.ssid = ss.id')xml into result FROM dual;
    On this both the reference to multiple tables and the concat function cause errors.
    Thank you
    Edited by: user583094 on Mar 2, 2011 3:36 PM

    Hi,
    for the concat do I use xmlconcat?No, XMLConcat is used to concatenate XMLType fragments.
    The || operator will do fine, but you must escape any single quote inside the string :
    SELECT DBMS_XMLGEN.getxml(
    'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = 8
    AND ra.fiscal_yr = 11
    AND ss.raid = ra.id
    AND st.ssid = ss.id'
    INTO result
    FROM dual;Or, use the quoting operator to define a custom string delimiter :
    SELECT DBMS_XMLGEN.getxml(
    q'{SELECT ra.prefix ||'-'|| ra.suffix ||'-'|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = 8
    AND ra.fiscal_yr = 11
    AND ss.raid = ra.id
    AND st.ssid = ss.id
    INTO result
    FROM dual;BTW, a good practice would be to use bind variables for the query. DBMS_XMLGEN can handle them nicely :
    CREATE OR REPLACE FUNCTION get_xml
    RETURN CLOB
    IS
    qryctx   DBMS_XMLGEN.ctxHandle;
    v_out    CLOB;
    qrystr   VARCHAR2(4000) :=
    'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
            ss.date_in,
            st.test
    FROM rcv.recv_accessions ra,
          ser.sero_samples ss,
          ser.sero_tests st
    WHERE ra.prefix = :b_prefix
    AND ra.fiscal_yr = :b_fiscal_yr
    AND ss.raid = ra.id
    AND st.ssid = ss.id';
    BEGIN
    qryctx := DBMS_XMLGEN.newContext(qrystr);
    DBMS_XMLGEN.setBindValue(qryctx, 'b_prefix', '8');
    DBMS_XMLGEN.setBindValue(qryctx, 'b_fiscal_yr', '11');
    -- to generate empty elements if necessary :
    DBMS_XMLGEN.setNullHandling(qryctx, DBMS_XMLGEN.EMPTY_TAG);
    v_out := DBMS_XMLGEN.getXML(qryctx);
    DBMS_XMLGEN.closeContext(qryctx);
    RETURN v_out;
    END;

  • How to query from the xml table a single, specified element.

    I'm quite new in Xml Db. Pleas, can anybody tell me how to query from the xml table below a single element (i.e. the element 'rapportoparentela = NIPOTE' related to the element 'codicefiscale = CRRVNC76R52G337R', or the element 'rapportoparentela = FIGLIO' related to the element 'codicefiscale = CRRRNT51L23G337Q')?
    - <dati xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <codiceinterno />
    <codicefiscaleassistito>CRRMNL81R31G337H</codicefiscaleassistito>
    - <famigliare>
    <codicefiscale>CRRVNC76R52G337R</codicefiscale>
    <rapportoparentela>NIPOTE</rapportoparentela>
    </famigliare>
    - <famigliare>
    <codicefiscale>CRRRNT51L23G337Q</codicefiscale>
    <rapportoparentela>FIGLIO</rapportoparentela>
    </famigliare>
    - <famigliare>
    <codicefiscale>CBRPRN15S65E080W</codicefiscale>
    <rapportoparentela>I.S.</rapportoparentela>
    </famigliare>
    - <famigliare>
    <codicefiscale>CRRMNL81R31G337H</codicefiscale>
    <rapportoparentela>NIPOTE</rapportoparentela>
    </famigliare>
    - <famigliare>
    <codicefiscale>BCCCML54C50I845G</codicefiscale>
    <rapportoparentela>NUORA</rapportoparentela>
    </famigliare>
    </dati>
    Using SELECT extractValue(value(t),'/rapportoparentela') into result FROM NF_XMLT X,
    TABLE ( xmlsequence (extract(value(X),'/dati/famigliare/rapportoparentela'))) t
    I get all the elements 'rapportoparentela' and I want to get only one specified.
    Regards.
    Piero

    Piero,
    you can add the condition "CRRVNC76R52G337R" to your xpath-expression like:
    SELECT extractValue(value(t),'/rapportoparentela')
    FROM NF_XMLT x
    ,TABLE ( xmlsequence (extract(value(X),'/dati/famigliare[rapportoparentela="CRRVNC76R52G337R"]'))) tto select only those famigliare-elements that have a child-element rapportoparentela with value "CRRVNC76R52G337R".
    When you stored your XML in an XMLType column in the table, i think the following queries are better:
    SELECT extractValue(x.your_XMLType_column,'/dati/famigliare/rapportoparentela')
    FROM NF_XMLT x
    WHERE extractValue(x.your_XMLType_column,'/dati/famigliare/codicefiscale')
    = 'CRRVNC76R52G337R'or
    SELECT extractValue(x.your_XMLType_column,'/dati/famigliare/rapportoparentela')
    FROM NF_XMLT x
    WHERE existsNode(x.your_XMLType_column,'/dati/famigliare[codicefiscale="CRRVNC76R52G337R"]')
    != 0

  • Sql query, from xml to nested table

    Hello!
    I have DB table: my_table
    It has 2 fields: file_id and file_data (it's clob with xml)
    I need to write query that returns info from xml using nested table (Oracle v.9)
    The number of rows witch will return query must be equal to number of files (file_id)
    Structure of XML:
    <?xml version = "1.0" encoding = "utf-8"?>
    <head>
    <AAA v1="a" v2="b">
    <BBB p1="1" p2="2"/>
    <BBB p1="3" p2="4"/>
    </AAA>
    <AAA v1="c" v2="d">
    <BBB p1="5" p2="6"/>
    <BBB p1="7" p2="8"/>
    <BBB p1="9" p2="0"/>
    </AAA>
    </head>
    I have query, witch works! but not optimally! each CLOB scaned 3 times - I want to scan it once!
    SELECT an.file_id,
    CAST(MULTISET(SELECT extract(VALUE(val2),'//@v1').getStringVal() v1,
    extract(VALUE(val2),'//@v2').getStringVal() v2,
    CAST(MULTISET(SELECT extract(VALUE(val3),'//@p1').getStringVal() p1,
    extract(VALUE(val3),'//@p2').getStringVal() p2,
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA/BBB[../@v1='||extract(VALUE(val2),'//@v1').getStringVal()||']'))) val3) AS T_VAL3) info
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA'))) val2) AS T_VAL2) head
    FROM (SELECT olr.*
    FROM my_table olr,
    TABLE (XMLSEQUENCE(XMLTYPE(file_data)).EXTRACT('/head'))) val1) an
    PLEASE, help me to rewrite this query!

    I assume you're using nested objects like these to hold the result?
    create type t_val3_rec as object ( p1 number, p2 number );
    create type t_val3 as table of t_val3_rec;
    create type t_val2_rec as object ( v1 varchar2(30), v2 varchar2(30), c1 t_val3 );
    create type t_val2 as table of t_val2_rec;
    /then this query should work :
    SELECT t.file_id
         , CAST(
             MULTISET(
               SELECT extractvalue(value(x1), '/AAA/@v1')
                    , extractvalue(value(x1), '/AAA/@v2')
                    , CAST(
                        MULTISET(
                          SELECT extractvalue(value(x2), '/BBB/@p1')
                               , extractvalue(value(x2), '/BBB/@p2')
                          FROM TABLE(XMLSequence(extract(value(x1), '/AAA/BBB'))) x2
                        AS t_val3
               FROM TABLE(XMLSequence(extract(value(x), '/head/AAA'))) x1
             AS t_val2
    FROM my_table t
       , TABLE(XMLSequence(extract(xmltype(t.file_data), '/head'))) x
    ;

  • Query DB2 tables from oracle using normal view

    This is with regard to querying db2 tables using oracle views. The view is created using dblink. The querying is not an one time activity.querying will be done once in a day. Can i use normal view (will it work ) or should i use materialised view. will i be able to view the added records in db2 table using normal view?
    thanks,
    vinodh

    Vinodh2 wrote:
    This is with regard to querying db2 tables using oracle views. The view is created using dblink. The querying is not an one time activity.querying will be done once in a day. Can i use normal view (will it work ) or should i use materialised view. will i be able to view the added records in db2 table using normal view?How can the SQL select statement via a dblink not work for a view, but the same SQL select statement work for a materialised view?
    Do you think the database link or remote database care whether the select SQL that hits it, comes from a PL/SQL procedure, a view, a materialised view, a job or whatever else? It has no idea what/who is behind that select SQL - and nor does it care.
    As for the benefits of a view vs. a materialised view - that depends on the requirements for needing to use that foreign database's data in the local database.

Maybe you are looking for

  • Podcast videos wont play in latest itunes

    I have the latest iTunes version for windows vista. I have been downloading podcast videos and it says done but then when I go to view it is no longer available as if I didnt ever download it and so it wont play. How do I download and view the podcas

  • Alv field no display

    Hi All, I am displaying a list using alv hierarchy report and I dont want the fields at the item level to diplay. I am using the fieldcat-tech = 'X' for this. Its working butthe allignment of the fields is getting disturbed. How can it be displayed p

  • Payment Grantee Procedure

    Hello In Sales Order Header.... Billing Tab there is a Payment Grantee Procedure and Financial Document Number. What is the use of these fields in Foreign Trade Data. How are these fields determined in Sales order and what is the impact of these fiel

  • Mail app crash when trying to choose contact

    If I try and compose a new email, when I hit the little plus sign to choose a contact, then I choose a contact from the table, the app crashes and takes me back to the home screen. If I type a contacts name in instead of hitting the plus sign everyth

  • Bt home hub phone.

    Since last night my home hub phone keeps coming up number unavailable whenever I try dialing,It started whilst I was in the middle of a call and just cut off.I've tried everything and nothing seems to work. It will dial out if I press 5 and then type