Table of the Union

Hi all
I have 2 tables TableA and TableB

TableA
Name, amount, Date

TableB
Name, Amt, BusinessDate

How to get all records in TableA, TableB (Union)
Join TableA.Date = TableB.BusinessDate

Note: above the table column name was different. (TableA. Amount and TableB.Amt)

Result:
Name, amount, Date
I should show all (Union records) in above the column name.

How to do this in OBIEE could you please me step by step

Thank you

Hi reda,.

Defined a level of aggregation (Sum) to the RPD for amount columns?

Thank you

Daan Bakboord
http://obibb.WordPress.com

Tags: Business Intelligence

Similar Questions

  • How can find data in a colum prj_no in all the table of the same schema

    Hi all

    I find the list of tables with data that has prj_no = "Axis_11" for all tables in the same schema.



    Thank you
    Nr

    PNR wrote:
    I find the list of tables with data that has prj_no = "Axis_11" for all tables in the same schema.

    1. find the tables with a column of PRJ_NO name. You can find it in USER_TAB_COLUMNS
    2 write a query to read the data in each table, using the UNION/UNION ALL operators to merge the results for each table

  • Values in the list by the order of table in SELECT Union

    Version: 11.2

    Apparently a very basic thing. But I couldn't do it :)

    In the UNION example below automatic sorting in is based on alphabetical order. I want to get rid of this sort and list the values according to the order of the table in the SELECT.

    Test data
    create table test1 (name1 varchar2(10));
    
    create table test2 (name2 varchar2(10));
    
    create table test3 (name3 varchar2(10));
    
    
    insert into test1 values ('EARTH');
    insert into test1 values ('TAURUS');
    insert into test2 values ('YELLOW');
    
    insert into test2 values ('ALPHA');
    insert into test2 values ('TANGO');
    
    
    insert into test3 values ('BRAVO');
    
    
    select name1 from test1
    union
    select name2 from test2
    union
    select name3 from test3;
    
    NAME1
    ----------
    ALPHA
    BRAVO
    EARTH
    TANGO
    TAURUS
    YELLOW
    
    6 rows selected.
    In the above example, I want the values in the first array SELECT listed first, then all the values of the second table in SELECT it and so on.

    Basically my requirement will be
    Return all values from test1 (alphabetically sorted)
    then
    Return all values from test2 (alphabetically sorted)
    then
    Return all values from test3 (alphabetically sorted)
    Expected results:
    NAME1
    ----------
    EARTH  ------------> from the first table in the SELECT
    TAURUS ------------> from the first table in the SELECT
    ALPHA  ----------------------> from the second table in the SELECT
    TANGO  ----------------------> from the second table in the SELECT
    YELLOW ----------------------> from the second table in the SELECT
    BRAVO  ------------------------------> from the third table in the SELECT

    Hello

    Union made a distinct in terms of the line. From the line "ALPHA", 2 and the line 'ALPHA', 3 are different, they both show in the result set.

    Further, you are all just lucky, that you get the results you want with the order clause:

    order by 2
    

    This performs a sort on the second column (1,2,3)
    Also, you want to sort on the first column (name1, name2 and Name3). The order clause should be (as already shown correctly abbove):

    order by
      2, 1
    

    Kind regards

    Peter

  • How to find the Union between the column in the table

    Hello

    I have the followin table and I want to find the union between the lines as below,
    create table test5 (tidset varchar2(200));
    
    insert into test5 values('1;2;3;4;5;6;7;8;9;10;11;12;13;15;16;17;18;19;20');
    insert into test5 values('1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20');
    insert into test5 values('1;2;3;4;6;7;8;9;11;12;13;15;16;19;20');
    insert into test5 values('1;4;6;10;6;11;12;13;14;15;16;17;18;19;20');
    I need the result to be as below.
    1;4;6;11;12;13;15;16;19;20
    any help please,.

    Published by: user11309581 on November 17, 2011 21:32

    Always mention what version of oracle you are using.

    The following query will give you the desired result oracle version 11g release 2.

    Connected to Oracle Database 11g Release 11.2.0.2.0 
    
    SQL>
    SQL> with test5 as
      2  (
      3  select '1;2;3;4;5;6;7;8;9;10;11;12;13;15;16;17;18;19;20' tidset from dual union all
      4  select '1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20' from dual union all
      5  select '1;2;3;4;6;7;8;9;11;12;13;15;16;19;20' from dual union all
      6  select '1;4;6;10;6;11;12;13;14;15;16;17;18;19;20' from dual
    -- "END OF SAMPLE DATA"
      7  ), all_items as
      8  (
      9    SELECT regexp_substr(t.tidset, '[^;]+', 1, column_value) item
     10          ,t.tidset
     11      FROM test5 t
     12          ,TABLE(CAST(MULTISET
     13                      (SELECT LEVEL
     14                         FROM dual
     15                       CONNECT BY LEVEL <=
     16                                  length(regexp_replace(t.tidset, '[^;]')) + 1) AS
     17                      sys.odcinumberlist))
     18  ),item_counts as
     19  (
     20    SELECT DISTINCT a.item
     21                   ,COUNT(DISTINCT a.tidset) over() total_tidset
     22                   ,COUNT(a.item) over(PARTITION BY a.item) item_occurance_count
     23      FROM (SELECT DISTINCT item
     24                           ,tidset
     25              FROM all_items) a
     26  )
     27  SELECT listagg(item, ';') within GROUP(ORDER BY to_number(item)) common_items
     28    FROM item_counts
     29   WHERE total_tidset = item_occurance_count
     30  ;
    
    COMMON_ITEMS
    --------------------------------------------------------------------------------
    1;4;6;11;12;13;15;16;19;20
    
    SQL> 
    

    OR if you have any version of oracle less than 11g release 2 then replace below mentioned line

    SELECT listagg(item, ';') within GROUP(ORDER BY to_number(item)) common_items
    

    with this one

    select xmlagg(xmlelement(c,item||';').extract('//text()') order by (to_number(item))) common_items
    

    It is because the listagg function used in above query is not supported in versions of oracle 11.2 below.

    I hope this helps.

    -Gregory

    Published by: Mohamed Diarra on November 18, 2011 01:05
    Extra line to be changed for the oracle version lower than 11.2

  • Update a table using the clause

    Hello

    I want to update a table using the selected values.

    Cases in the sample:


    create table as empsalary)

    Select 1 as empid, 0 in the wages of all the double union

    Select option 2, the double 0);

    Data update are as follows

    with saldata as

    (

    Select 1 as empid, 5000 as wages, 500 as double pf

    Union of all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    I tried the following query but does not work

    updated set of empsalary table (empid, salary) =

    (

    Select * from)

    with saldata as

    (

    Select 1 as empid, salary, 500 5000 as pf Union double all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    ) sl

    where sl.empid = empsalary.empid

    )

    I use oracle 10g.

    Help, please.

    Krishna Devi wrote:

    Hello

    I want to update a table using the selected values.

    Cases in the sample:

    create table as empsalary)

    Select 1 as empid, 0 in the wages of all the double union

    Select option 2, the double 0);

    Data update are as follows

    with saldata as

    (

    Select 1 as empid, 5000 as wages, 500 as double pf

    Union of all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    I tried the following query but does not work

    updated set of empsalary table (empid, salary) =

    (

    Select * from)

    with saldata as

    (

    Select 1 as empid, salary, 500 5000 as pf Union double all the

    Select option 2, 10000,1000 like double pf

    )

    Select empid, salary saldata

    ) sl

    where sl.empid = empsalary.empid

    )

    I use oracle 10g.

    Help, please.

    Thanks for posting creates table and test data.

    The error message would have helped because it's pretty obvious that this is the problem:

    Update table empsalary

    *

    ERROR on line 1:

    ORA-00903: invalid table name

    Just remove the word "table".

  • Please help me with the Alternative of queries to replace the UNION ALL for two queries

    Hi all

    I have the query to retrieve assets employees salary count and in so far as below:

    Select ename, emp_no, sum (sal_till_2010), sum (sal_till_2014) of

    (select emp_no, ename, salary as sal_till_2010, 0 as sal_till_2014 of employee e1

    where effective_date < = 1 January 2010 ' and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = January 1, 2010 "")

    UNION ALL

    Select ename, emp_no, 0 as sal_till_2010, salary as employee e1 sal_till_2014 - here is a dummy 0 salary until 2010 for the union of all the

    where effective_date < = 1 January 2014 "and not exists (select 1 from e2 employee_deletion where e2.emp_no = e1.emp_no and e2.deletion_date < = 1 January 2014") "

    Group of emp_no, ename;

    In this query, I get the total salary until 2010 and until 2014 in the employee table, dates are dynamically passed to the procedure, and this can change.

    But assume the date above and let me know the alternative of queries to improve performance because I use Union ALL and read the same table twice in the above query.

    Advice me with request to read the table once to fetch the same data as the above query.

    Thanks in advance.


    Hello

    Thanks for the display of the data of the sample; It's very useful!

    I think OP wants something like this:

    WITH cutoff_dates AS

    (

    SELECT TO_DATE (January 1, 2010 ', ' DD/MM/YYYY') AS cutoff_date, 2010 UNDER the label OF dual UNION ALL

    SELECT TO_DATE (1 January 2014 ', "DD/MM/YYYY"), double 2014

    )

    SELECT e.emp_no, e.ename

    , NVL (SUM (CASE WHEN c.label = 2010 THEN e.salary END), 0) AS sal_till_2010

    , NVL (SUM (CASE WHEN c.label = 2014 THEN e.salary END), 0) AS sal_till_2014

    E employee

    JOIN cutoff_dates c ON e.effective_date<=>

    WHERE DOES NOT EXIST)

    SELECT 1

    Of employee_deletion ed

    WHERE ed.emp_no = e.emp_no

    AND ed.deletion_date<=>

    )

    E.emp_no GROUP, e.ename

    ORDER BY e.emp_no

    ;

    Output of your sample data:

    EMP_NO ENAME SAL_TILL_2010 SAL_TILL_2014

    ---------- ------ ------------- -------------

    1 Mickey 450 0

    2 Donald 750 0

  • Using Clob in the Union query

    Hello everyone, have a look at the statements below and let me know what wrong with my approach.

    CREATE TABLE test
    (column1 CLOB);
    
    
    INSERT INTO test 
    SELECT to_clob('This is test') FROM dual;
    

    When I run the query below, I get data types incompatible error (ORA-00932). Help, please.

    SELECT to_clob('This is test two') FROM dual 
    UNION
    SELECT column1 FROM test;
    

    Kind regards

    Shiva.

    Hey Shiva,

    Copied from documentation

    http://docs.Oracle.com/CD/B19306_01/server.102/b14200/queries004.htm

    Restrictions on operators define the set operators are subject to the following restrictions:

    • Set operators are not valid on columns of type BLOB , CLOB , BFILE , VARRAY , or a nested table.
    • The UNION , INTERSECT , and MINUS operators are not valid on LONG columns.
    • If the selection list prior the operator set contains an expression, you must provide an alias for the expression column to refer in the order_by_clause .
    • You cannot specify also the for_update_clause with the set operators.
    • You cannot specify the order_by_clause in the subquery of these operators.
    • You cannot use these operators in SELECT statements containing the TABLE expressions collection.
  • How to export data to excel that has 2 tables with the same number of columns and the column names?

    Hi everyone, yet once landed upward with a problem.

    After trying many things to myself, finally decided to post here...

    I created a form in form builder 6i in which clicking on a button, the data gets exported to the excel sheet.

    It works very well with a single table. The problem now is that I cannot do the same with 2 tables.

    Because the tables have the same number of columns and the columns names.

    Here are the 2 tables with column names:

    Table-1 (MONTHLY_PART_1) Table-2 (MONTHLY_PART_2)
    SL_NOSL_NO
    MODELMODEL
    END_DATEEND_DATE
    U-1U-1
    U-2U-2
    U-4U-4
    ..................
    ..................
    U-20U-20
    U-25U-25

    Given that the tables have the same column names, I get the following error :

    402 error at line 103, column 4

    required aliases in the SELECT list of the slider to avoid duplicate column names.

    So how to export data to excel that has 2 tables with the same number of columns and the column names?

    Should I paste the code? Should I publish this query in 'SQL and PL/SQL ' Forum?

    Help me with this please.

    Thank you.

    Wait a second... is this a kind of House of partitioning? Shouldn't it is a union of two tables instead a join?

    see you soon

  • Another way for the UNION

    I'm trying to get this result,

    EQPID EVENTVAL 20120501 20120502 20120503 201204 201205
    -------------------------------------------------------------------------------------------------------------------
    MS - A1 21528 28386 18288 821295 908602 TKINQTY
    MS - A1 21510 28359 18270 820470 907321 TKOUTQTY
    MS - B1 21090 17990 15750 467922 557239 TKINQTY
    MS - B1 21080 17982 15735 467495 556730 TKOUTQTY
    MS - C1 35548 23848 26082 914351 1013655 TKINQTY
    MS - C1 35533 23826 26058 913727 1012888 TKOUTQTY
    MS - D1 22680 17568 15030 514467 494510 TKINQTY
    MS - D1 22660 17565 15021 513955 493857 TKOUTQTY
    MS - E1 18450 20916 20754 429057 490732 TKINQTY
    MS - E1 18436 20912 20739 428564 490188 TKOUTQTY
    MS - F1 13968 14436 14670 440760 517343 TKINQTY
    MS - F1 13949 14409 14657 440364 516870 TKOUTQTY
    MS - G1 21060 21600 25240 573409 460286 TKINQTY
    MS - G1 21057 21595 25237 573317 459888 TKOUTQTY
    MS - H1 16452 19278 21456 510192 545201 TKINQTY
    MS - H1 16452 19278 21456 510174 545174 TKOUTQTY
    170776 164022 157270 4671453 4987568 TKINQTY
    170677 163926 157173 4668066 4982916 TKOUTQTY
    341453 327948 314443 9339519 9970484


    in this table

    CUTOFF_DATE EQPID TKINQTY TKOUTQTY
    -------------------------------------------------------------------------
    20120401 MS - A1 46566 46524
    20120401 MS - B1 13734 13720
    and so on...

    Here is my code,

    SELECT EQPID, «EVENTVAL' AS «EVENTVAL', SUM("20120501") AS '20120501', SUM("20120502") AS '20120502', SUM("20120503") AS '20120503', SUM("201204") "201204" AS, SUM("201205") "201205" AS
    Of
    (
    SELECT EQPID, «EVENTVAL' AS «EVENTVAL', SUM("20120501") AS '20120501', SUM("20120502") AS '20120502', SUM("20120503") AS '20120503', SUM("201204") "201204" AS, SUM("201205") "201205" AS
    Of
    (
    SELECT EQPID,
    CASE
    WHEN EQPID LIKE 'MS-% '.
    THEN "TKINQTY".
    END, LIKE "EVENTVAL."

    CASE
    WHEN CUTOFF_DATE = '20120501'
    THEN SUM (QTY)
    END, LIKE "20120501."

    CASE
    WHEN CUTOFF_DATE = '20120502'
    THEN SUM (QTY)
    END, LIKE "20120502."

    CASE
    WHEN CUTOFF_DATE = '20120503'
    THEN SUM (QTY)
    END, LIKE "20120503."

    CASE
    WHEN CUTOFF_DATE BETWEEN '20120401' AND '20120430'
    THEN SUM (QTY)
    END AS "201204."

    CASE
    WHEN CUTOFF_DATE BETWEEN '20120501' AND '20120530'
    THEN SUM (QTY)
    END AS "201205.

    Of
    (
    SELECT CUTOFF_DATE, EQPID, SUM (TKINQTY) QTY.
    OF DAILY_DATA
    WHERE CUTOFF_DATE BETWEEN '20120401' AND '20120530'
    AND EQPID LIKE 'MS-%'
    CUTOFF_DATE GROUP, EQPID
    ORDER BY CUTOFF_DATE, EQPID
    )
    EQPID GROUP, CUTOFF_DATE
    )
    EVENTVAL GROUP, EQPID
    UNION
    SELECT EQPID, 'EVENTVAL' AS 'EVENTVAL', SUM("20120501") AS '20120501', SUM("20120502") AS '20120502', SUM("20120503") AS "20120503", SUM("201204") AS "201204', SUM("201205") AS"201205 '"
    Of
    (
    SELECT EQPID,
    CASE
    WHEN EQPID LIKE 'MS-% '.
    THEN "TKOUTQTY".
    END, LIKE "EVENTVAL."

    CASE
    WHEN CUTOFF_DATE = '20120501'
    THEN SUM (QTYO)
    END, LIKE "20120501."

    CASE
    WHEN CUTOFF_DATE = '20120502'
    THEN SUM (QTYO)
    END, LIKE "20120502."

    CASE
    WHEN CUTOFF_DATE = '20120503'
    THEN SUM (QTYO)
    END, LIKE "20120503."

    CASE
    WHEN CUTOFF_DATE BETWEEN '20120401' AND '20120430'
    THEN SUM (QTYO)
    END AS "201204."

    CASE
    WHEN CUTOFF_DATE BETWEEN '20120501' AND '20120530'
    THEN SUM (QTYO)
    END AS "201205.

    Of
    (
    SELECT CUTOFF_DATE, EQPID, SUM (TKOUTQTY) QTYO
    OF DAILY_DATA
    WHERE CUTOFF_DATE BETWEEN '20120401' AND '20120530'
    AND EQPID LIKE 'MS-%'
    CUTOFF_DATE GROUP, EQPID
    ORDER BY CUTOFF_DATE, EQPID
    )
    EQPID GROUP, CUTOFF_DATE
    )
    EVENTVAL GROUP, EQPID
    )
    GROUP BY ROLLUP (EVENTVAL, EQPID)
    ORDER OF EQPID, EVENTVAL


    It seems to be so long, and I try to avoid the UNION...
    Is there an alternative way to achieve the same result without the help of the union?

    Thank you

    Estelle =)

    Published by: 1004902 on May 8, 2013 17:52

    Published by: 1004902 on May 8, 2013 17:59

    Hello

    Welcome to the forum!

    1004902 wrote:
    I'm trying to get this result,

    EQPID EVENTVAL 20120501 20120502 20120503 201204 201205
    -------------------------------------------------------------------------------------------------------------------


    MS - A1 21528 28386 18288 821295 908602 TKINQTY
    MS - A1 21510 28359 18270 820470 907321 TKOUTQTY
    ...
    in this table

    CUTOFF_DATE EQPID TKINQTY TKOUTQTY
    -------------------------------------------------------------------------
    20120401 MS - A1 46566 46524
    20120401 MS - B1 13734 13720
    and so on...

    Every time you ave a problem, CREATE TABLE post and instructions INSERT for your sample data and the results you want from this data.
    Explain how you get these results from these data.
    Always say what Oracle version you have (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

    It seems that the UNION may be replaced by a cross join, or SELECT... UNPIVOT depending on what version of Oracle you are running.

    Published by: Frank Kulash on May 8, 2013 21:52

    You may want something like this:

    WITH    cntr    AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL     <= 2
    )
    ,     got_eventval     AS
    (
         SELECT       d.cutoff_date
         ,        d.eqpid
         ,       CASE
                    WHEN  c.n = 1  THEN  'TKINQTY'
                                       ELSE  'TKOUTQTY'
                END     AS eventval
         ,       CASE
                    WHEN  c.n = 1  THEN  d.tkinqty
                                       ELSE  d.tkoutqty
                END     AS qty
         FROM         daily_data  d
         CROSS JOIN  cntr     c
         WHERE    cutoff_date BETWEEN '20120401'
                         AND     '20120530'
            AND       eqpid           LIKE 'MS-%'
    )
    SELECT       eqpid, eventval
    ,       SUM (CASE WHEN cutoff_date = '20120501'  THEN qty END)  AS "20120501"
    ,       SUM (CASE WHEN cutoff_date = '20120502'  THEN qty END)  AS "20120502"
    ,       SUM (CASE WHEN cutoff_date = '20120503'  THEN qty END)  AS "20120503"
    ,       SUM (CASE WHEN cutoff_date LIKE '201204' THEN qty END)  AS "201204"
    ,       SUM (CASE WHEN cutoff_date LIKE '201205' THEN qty END)  AS "201205"
    FROM       got_eventval
    GROUP BY  eqpid, eventval
    ORDER BY  eqpid, eventval
    ;
    

    Of coursel, I can't test it until you post the sample data.

    Storage of the information on the dates in a column VARCHAR2 is a very bad idea. The columns DATE to the date information.

  • Combine the results of the UNION

    I have little experience with the UNION or UNION ALL, so I don't know what I'm doing wrong. I would like to get the lines in the 2nd statement that is to be United to be grouped with the lines of the first statement, that they must also be included in the total of the column. Here is my SQL and the results I get. Any help is appreciated.

    Select
    TRUNC (phy_pay_date, 'MONTH') MONTH.
    MNTH NULL,
    Count (distinct (decode (phy_prn_code, 'WEEK', phy_emp_no))) WEEK,.
    Count (distinct (decode (phy_prn_code, 'SEMI', phy_emp_no))) SEMI.
    Count (distinct (decode (phy_prn_code, 'MONTH', phy_emp_no))) +.
    Count (distinct (decode (phy_prn_code, 'SEMI', phy_emp_no))) +.
    Count (distinct (decode (phy_prn_code, 'WEEK', phy_emp_no))) TOTAL

    of da.pyemppayhist
    da.pyworkloc
    da.pycompayprd
    where wrl_code = phy_work_location
    and phy_prn_code = ppr_prn_code
    and phy_comp_code = ppr_comp_code
    and phy_ppr_period = ppr_period
    and phy_ppr_year = ppr_year
    and phy_ppr_year = '2012'
    and 12 between extract (ppr_start_date days) and (ppr_end_date days)
    Trunc Group (phy_pay_date, 'MONTH')

    UNION ALL

    Select
    MONTHS OF NULL,
    Count (distinct (decode (phy_prn_code, 'MONTH', phy_emp_no))) MONTHS.
    WEEK NULL,.
    NULL SEMI,
    TOTAL NULL VALUE

    of da.pyemppayhist
    da.pyworkloc
    da.pycompayprd
    where wrl_code = phy_work_location
    and phy_prn_code = ppr_prn_code
    and phy_comp_code = ppr_comp_code
    and phy_ppr_period = ppr_period
    and phy_ppr_year = ppr_year
    and phy_ppr_year = '2012'
    Trunc Group (phy_pay_date, 'MONTH')
    order by MONTH
    MONTH     MNTH WEEK SEMI TOTAL
    --------- ---- ---- ---- -----
    01-JAN-12       112  235   347 
    01-FEB-12       109  233   342 
    01-MAR-12       101  230   331 
    01-APR-12       107  226   333 
    01-MAY-12       107  224   331 
    01-JUN-12       109  221   330 
    01-JUL-12       108  223   331 
                20                 
                24                 
                23                 
                29                 
                31                 
                34                 
                45                 

    I don't think you need the Union, all at all - I think that you can do in a single query, if I understand your needs:

    select TRUNC (phy_pay_date, 'MONTH') MONTH,
           count(distinct(decode(phy_prn_code, 'MNTH', phy_emp_no))) MNTH MNTH,
           count(distinct(case when 12 between extract(day from ppr_start_date) and extract(day from ppr_end_date)
                                    and phy_prn_code = 'WEEK'
                                    then phy_emp_no
                          end)) WEEK,
           count(distinct(case when 12 between extract(day from ppr_start_date) and extract(day from ppr_end_date)
                                    and phy_prn_code = 'SEMI'
                                    then phy_emp_no
                          end)) SEMI,
           count(distinct(case when 12 between extract(day from ppr_start_date) and extract(day from ppr_end_date)
                                    and phy_prn_code = 'MNTH'
                                    then phy_emp_no
                          end)) +
             count(distinct(case when 12 between extract(day from ppr_start_date) and extract(day from ppr_end_date)
                                      and phy_prn_code = 'SEMI'
                                      then phy_emp_no
                            end)) +
             count(distinct(case when 12 between extract(day from ppr_start_date) and extract(day from ppr_end_date)
                                      and phy_prn_code = 'WEEK'
                                      then phy_emp_no
                            end)) TOTAL
    from da.pyemppayhist
    ,da.pyworkloc
    ,da.pycompayprd
    where wrl_code = phy_work_location
    and phy_prn_code = ppr_prn_code
    and phy_comp_code = ppr_comp_code
    and phy_ppr_period = ppr_period
    and phy_ppr_year = ppr_year
    and phy_ppr_year = '2012'
    group by trunc (phy_pay_date, 'MONTH')
    order by MONTH;
    

    One thing - you don't are not explicitly indicating which column is from which table, which is something that is vital (IMO) when working with 2 or more tables being joined. Not only does that help you to work if you missed a join condition, it is easier for other people to see what you've done. I highly recommend you rewrite your query with table aliases and then use these aliases for your column names - for example:

    select t1.col1, t2.col3, t3.col2
    from   table1 t1, table2 t2, table3 t3
    where  t1.col1 = t2.col1
    and    t3.col1 = t2.col2;
    
  • Several physical Tables in the single context

    I have a scenario and need your input in how to solve this problem.
    Let's say I have the schema from source database 2 S1 and S2 (on various Oracle Instances or a single instance). Both have the EMPLOYEE table. Now, I need to create a logical schema that maps to S1. EMPLOYEE and S2. USED, which is I should have access to the data of these two tables in the schema.

    Is this possible. Maybe they both have different sets of records of EMPLOYEES for my warehouse I need a UNION of all the data. If I use the context then at any time I can only connect to 1 of these tables. What I want is that in 1 context both have access.

    How can achieve us in ODI?

    >

    If the topology would be something like:

    Assuming that these are 2 scheme on a single database server
    1 / I 1 physical database server

    fix

    2 / 2 physical diagrams (S1 and S2)

    fix

    3 / context? How many?

    1

    Figure 4 / logic? How many?

    2

  • By comparing the two tables for the integrity of the data

    Hi all
    I need to compare two tables for the integrity of the data through the SQL query.

    If you need to compare all the columns of t1 to t2:

    (SELECT * FROM t1
    MINUS
    SELECT * FROM t2)
    UNION ALL
    (SELECT * FROM t2
    MINUS
    SELECT * FROM t1);
    

    Kind regards
    Ankit Rouault
    http://theoraclelog.blogspot.in

  • query MySQL (search multiple tables in the database)

    I have 12 tables in a database - January to December.

    I need to find all the tables 'keyworrd' 12 phrases submitted by the user via a search form.

    Need to create a simpler way to do as below with 'UNION '. I have incorporated 2 tables in the query below, but I need a query more "condensed" for all tables of 12?

    $sql = (' SELECT * FROM January WHERE tourTitle = "'.") $keyword. "' UNION SELECT * FROM February WHERE tourTitle = ' '. '" $keyword.' » ") ;

    See you soon

    Operating system

    Booth wrote:

    > That's what I did last year, but thought I would break down this year in 12 easier to work with tables.

    No, Ben is correct. 1 using table for each month is absolutely the wrong way. It violates the basic rules of standardization and causes all sorts of problems.

    > Breaking down appealed to be more so I can keep all these months

    > together instead of potentially become scattered across a table.

    That's what you use the Order By clause for.

    > If by chance the customer says they want to update x, y or z, I can go

    > straight for the month in question, without the need to browse

    > dozens of pages in phpMyAdmin, because there are no real management CMS in place for this process.

    Don't know what you're saying. Performing inserts, updates and queries is much easier using a single table.

    Whenever someone asks for a way to search through more than one table, he told me that the data structure is not well designed.

    When I did this job last year there were about 60 pages created in phpMyAdmin. Records of January could be anywhere on these 60 pages I might add on additional folders much later in the process.

    My thought behind this was to combine all entries of the month so I could view them easily in phpMyAdmin.

    Now, due to my lack of knowledge on phpMyAdmin, it would be possible to create a query to show only entries from January, I suspect that she can do.

    I agree it is much simpler using 1 table to select and browse BUT I need if the opportunity presents itself to be able to view all entries January or February etc. one after another, not 10 on page 2 and 3 on page 7 and 5 more to page 47 of phpMyAdmin.

    So I quess what I really need, it is write a select query in phpMyAdmin that shows only the entries selected for the requested month. I did not much research into what phpMyAdmin can do... so I guess I have to.

    PUBLISHED:

    Arrgh, you see it WAS so SIMPLE:

    SELECT * FROM 'towers' months WHERE = "March".

    It's because I'm afraid of the bloody thing in case I mess up something!

  • How to eliminate the union clause

    I have a requirement where I need to get some recording (say 5 records) of the table and the sum (TOTAL) of some columns in these 5 folders that should be displayed as the last record. Im trying it work with union all clause

    Select cd
    pid
    dt
    number
    type
    sum (iamt) iamt
    sum (ALMPs) ALMPs
    sum (oamt) oamt
    idt
    from t1
    where code = 'NAQ.
    Group by cd, pid, dt, idt
    Union of all the
    Select 'TOTAL '.
    null
    null
    null
    null
    sum (iamt) iamt
    sum (ALMPs) ALMPs
    sum (oamt) oamt
    null
    from t1
    where code = 'NAQ;

    is there a way I can avoid using the UNION clause and achieve the same...? Kindly share your thoughts...

    Hello

    Try below:
    SELECT cd,
    nest,
    DT,
    NUMBER,
    TYPE,
    Sum (iAMT) iamt,
    Sum (ALMPS) ALMPs,
    Sum (OAMT) oamt,
    IDT
    FROM t1
    WHERE code = 'NAQ.
    GROUP BY GROUPING SETS ((dt, cd, pid, NUMBER, idt), NULL)

    Kind regards
    Karine

  • How to find the data in two tables are the same?

    Hi people,

    Suppose we have table emp01, have 10 records and create another emp02 as table

    create the table emp02 in select * from emp01;

    now both the table has the same data.

    How to find a 'data' in the two tables are the same?

    Hello

    SELECT *
    FROM emp01
    MINUS
    SELECT *
    FROM emp02
    UNION
    SELECT *
    FROM emp02
    MINUS
    SELECT *
    FROM emp01
    

    You can also compare resultset hash to select * in emp01 and select * from emp02 by using dbms_sqlhash.

    Best regards
    Nikolai

Maybe you are looking for