Multiple Table join result problem

Hello

I am new to oracle

I am facing a problem to the exact result of multiple table.
My query is


Select e . e_name, t . Start_date, a. area_name , t . Branch of the , t . objective, ( t. actual_rtn_dt - t . Start_date) duration

t of tour_info zone a, e method

where actual_rtn_dt is not null

and t. emp_code = e. emp_code

     and t. zone = a. Area_Code

order t. start_date;

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

Here is the result

MD. KHAIRUL ISLAM01 SEP-14DHAKA_3071AUTOMATION6
DEV SUDORSON02-SEP-14TRAINING DIISP2
JUSTINE DIA04 SEP-14GAZIPURHUMAN RESOURCES REVIEW0
SABRI AL RAHMAN04 SEP-14DHAKA_3071AUTOMATION WITH PKSF3
MD. KHALEDUL ISLAM04 SEP-14GAZIPURHUMAN RESOURCES REVIEW0
GAZI MD. SALAHUDDIN04 SEP-14GAZIPUR0
MD. KHALEDUL ISLAM06 SEP-14071AUTOMATION0
MD. JULIEE RAHMAN14-SEPT-11GAZIPURTRAINING2

But I want to, in Bracnh column allows to extract branch_name Bracnh Tbal (I have on the database) as Area_name.

How is it Possible?

Thanks advanced

SELECT e.e_name,
       t.start_date,
       a.area_name,
       --t.branch,
       (select branch_name from branch_tbl where =t.branch) branch_name,
       t.objective,
       ( t.actual_rtn_dt - t.start_date ) duration
FROM   tour_info t,
       area a,
       emp_info e
WHERE  actual_rtn_dt IS NOT NULL
       AND t.emp_code = e.emp_code
       AND t.area = a.area_code(+)
ORDER  BY t.start_date;

Is that what you are looking for?

Tags: Database

Similar Questions

  • CF8 cfquery multiple table join with the same names of columns - default

    This seems to be a defect in the CF8 cfquery object. I'm at a loss as to a solution or a good work around. With regard to the substance, this query is generated dynamically on the fly based on what is happening in it a user. This isn't the most elegent SQL but work and return all columns. The app itself is a data viewer to look at the logs. Here is an example of a query being generated.

    Select *.

    of web_trans, web_info_trans, web_res_trans

    where (web_info_trans.trans_dte > = '' 2008-12-1)

    and web_info_trans.trans_dte < '' 2008-12-2)

    and (web_info_trans.trans_dte = web_trans.trans_dte)

    and (web_info_trans.trans_num = 5060345)

    and (web_info_trans.trans_num = web_trans.trans_num)

    and (web_res_trans.trans_num = 5060345)

    and (web_res_trans.trans_num = web_trans.trans_num)

    and (web_trans.web_trans_cde = "NTUI")

    and (web_trans.web_status_cde = 'P')

    and (web_trans. TRANS_NUM < 5060347)

    order of web_trans. TRANS_NUM / / desc

    These three tables contain a similar column called ZIP_CDE. They contain different values, and when this query is executed in Microsoft Query Analyzer results are displayed correctly. Run this same query SQL with CFQUERY and the value of one of the other tables (web_trans) will eventually replace the value for the other columns called ZIP_CDE. The exact amount columns are retruned only values some how get corrupted.

    This is a defect of cf8 is a book autour or an update that resolves this problem that I may have missed?

    Thank you for the ideas.

    Thus it seems still as a default since CF is essentially where, except for the return value play. Other query tools return results correctly so for me, it turns out be CF bug at a certain level.

    Actually I'm swinging to agree with you here, but not for the same reason.  CF actually * is * get all the columns back (as you say), it just doesn't expose a way to tell the difference between a column called 'x' and an another column called 'x', because the way to access the data in columns is simple queryname [columnName] [rowNumber] (or a Variant fo this, but all the amount of variations to that or abbrev. it).  This code shows how he has all four columns of the original two queries (being a stand-in for tables, in this case):


    Q1 = queryNew("");
    Q2 = queryNew("");
       
    queryAddColumn (q1, 'id', [1,2,3,4]);
    queryAddColumn (q1, "data", ["one", "two", "three", "four"]);
    queryAddColumn (q2, 'id', [1,2,3,4]);
    queryAddColumn (q2, "data", ["tahi", "rua", "toru", "wha"]); It's Maori, in case you are interested


    SELECT *.
    Q1, q2
    WHERE q1.id = q2.id

    So CF knows there are four columns (a call getMetadata (q3) get also demonstrates this), but it does not expose a way to approach the second (or even greater) column of the same name.  This is the bug/shortfall.

    However, relying on an underlying coldfusion.sql.QueryTable method, you can rename the columns, so:

    Then you're OK.

    I would be normally reluctant to recommend doing this, because these methods change from version to version of CF, but it's your call whether this approach will help you.

    To be honest, I'm with Owain who, even in SQL one generally doesn't work with columns with the same name, an alias them qualified with a table name/alias. As the table columns from of is not returned by SQL with the result set, it must be evidence against this by folding the columns in the first place.

    Also, I wonder at the bottom of the extraction of data, you don't really know the structure, that is to say, do SELECT *.  How can you know not even that is ours as the first column, second column, etc.?  I don't think that SQL applies in fact a contract that, t - it?  (I don't know).

    What are you actually do here?

    --

    Adam

  • Multiple Table join without loss of data - SQL help

    Hello
    I have the following tables 3 employee as indicated in the scripts below, please help in writing SQL that connects all these 3 tables and displays the output as shown below

    Required output
    EMP ID Loc Value 1 Value 2 Value 3                    
    1     A     3     1     6
    1 B 4 9 null
    Value null null 1 Wh 8
    2 Z 4 9 null
    3 R 0 null 1
    4 Y 1 null null
    5 O 7 7 null
    Value null null 5 Wh 5
    6 M 7 null 7
    6 B null null 8

    / * Create Tables * /.
    Create table Emp1 (Empid number, Loc Varchar2 (10), Value_1 number);
    Create the Emp2 Table (Empid number, Loc Varchar2 (10), Value_2 number);
    Create table emp3 (empid number, loc varchar2 (10), Value_3);

    / * Insert Scripts * /.
    Insert Into Emp1 Values (1, 'A', 3);
    Insert Into Emp1 Values (2, 'Z', 4);
    Insert Into Emp1 Values (3, 'R', 0);
    Insert Into Emp1 Values (4, 'Y', 1);
    Insert Into Emp1 Values (5, 'o', 7);
    Insert Into Emp1 Values (6, am', 7);

    Insert Into Emp2 Values (1, 'A', 1);
    Insert Into Emp2 Values (1, 'B', 4);
    Insert Into Emp2 Values (1, 'Wh', 8);
    Insert Into Emp2 Values (2, 'Z', 9);
    Insert Into Emp2 Values (5, 'o', 7);
    Insert Into Emp2 Values (5, 'Wh', 5);

    Insert Into Emp3 Values (1, 'A', 6);
    Insert Into Emp3 Values (1, 'B', 9);
    Insert Into Emp3 Values (3, 'R', 1);
    Insert Into Emp3 Values (6, am', 7);
    Insert Into Emp3 Values (6, 'B', 8);
    Commit;


    Thank you
    Varun

    Like this?

    SQL> select nvl(e.empid, e3.empid) empid
      2       , nvl(e.loc, e3.loc) loc
      3       , e.value_1
      4       , e.value_2
      5       , e3.value_3
      6    from (
      7            select nvl(e1.empid, e2.empid) empid
      8                 , nvl(e1.loc, e2.loc) loc
      9                 , e1.value_1
     10                 , e2.value_2
     11              from emp1 e1
     12              full join emp2 e2
     13                on e1.empid = e2.empid
     14               and e1.loc = e2.loc
     15         ) e
     16    full join emp3 e3
     17      on e.empid = e3.empid
     18     and e.loc = e3.loc
     19   order
     20      by empid
     21       , loc
     22  /
    
         EMPID LOC           VALUE_1    VALUE_2    VALUE_3
    ---------- ---------- ---------- ---------- ----------
             1 A                   3          1          6
             1 B                              4          9
             1 Wh                             8
             2 Z                   4          9
             3 R                   0                     1
             4 Y                   1
             5 O                   7          7
             5 Wh                             5
             6 B                                         8
             6 M                   7                     7
    
    10 rows selected.
    
    SQL> 
    
  • Optimizer (?) excluded table join

    Hello

    I have a problem. We use 10.2.0.5.0 database. I discovered very weird behavior when running a very simple three-table join. I tried two forms of the same join. The first was:

    SELECT

    NVL(c.cen_za_ks,1) as a2,

    NVL(c.cen_za_kg,1) like a3

    Of

    vymenny_urad VIEW

    JOIN IN-HOUSE

    Krajina K ON vu.vymur_krj_id = K.KRJ_ID

    JOIN IN-HOUSE

    CENNIK_090 C ON C.CEN_KR_KOD = K.KRJ_KOD

    WHERE

    vu.vymur_id = AND c.cen_kategoria = 369 has '

    Execution plan for this selection is:

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

    | ID | Operation | Name               | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |                    |     4.    88.     5 (0) | 00:00:01 |

    |   1.  NESTED LOOPS |                    |     4.    88.     5 (0) | 00:00:01 |

    |*  2 |   INDEX UNIQUE SCAN | IX_PK_VYMENNY_URAD |     1.       |     1 (0) | 00:00:01 |

    |*  3 |   TABLE ACCESS FULL | CENNIK_090 |     4.    56.     3 (0) | 00:00:01 |

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

    Information descriptor (identified by the operation identity card):

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

    2 - access("VU".") VYMUR_ID "= 369)

    3 - filter("C".") CEN_KATEGORIA "(='D')"


    Thus, for specific settings, I had 8 rows


    If I added any column of krajina of table columns selected like this:


    SELECT

    krj_id,

    NVL(c.cen_za_ks,1) as a2,

    NVL(c.cen_za_kg,1) like a3

    Of

    vymenny_urad VIEW

    JOIN IN-HOUSE

    Krajina K ON vu.vymur_krj_id = K.KRJ_ID

    JOIN IN-HOUSE

    CENNIK_090 C ON C.CEN_KR_KOD = K.KRJ_KOD

    WHERE

    vu.vymur_id = AND c.cen_kategoria = 369 has '


    the execution plan has been changed to:


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

    | ID | Operation | Name               | Lines | Bytes | Cost (% CPU). Time |

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

    |   0 | SELECT STATEMENT |                    |     1.    29.     6 (0). 00:00:01 |

    |   1.  NESTED LOOPS |                    |     1.    29.     6 (0). 00:00:01 |

    |   2.   NESTED LOOPS |                    |     1.    15.     3 (0) | 00:00:01 |

    |*  3 |    TABLE ACCESS BY INDEX ROWID | VYMENNY_URAD |     1.     8.     2 (0) | 00:00:01 |

    |*  4 |     INDEX UNIQUE SCAN | IX_PK_VYMENNY_URAD |     1.       |     1 (0) | 00:00:01 |

    |   5.    TABLE ACCESS BY INDEX ROWID | KRAJINA |   244.  1708.     1 (0) | 00:00:01 |

    |*  6 |     INDEX UNIQUE SCAN | PK_KRAJINA |     1.       |     0 (0) | 00:00:01 |

    |*  7 |   TABLE ACCESS FULL | CENNIK_090 |     1.    14.     3 (0) | 00:00:01 |

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

    Information of predicates (identified by the operation identity card):

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

    3 - filter("VU".") VYMUR_KRJ_ID"< 2147483648)

    4 - access("VU".") VYMUR_ID "= 369)

    6 - access("VU".") VYMUR_KRJ_ID '=' K '. ("' KRJ_ID")

    7 - filter("C".") CEN_KATEGORIA "= A"AND "C". ". CEN_KR_KOD '=' K '. ("' KRJ_KOD")

    and result set had only 2 rows, because of the restriction imposed by the table "krajina", which was not in the first case considered by the optimizer.

    Y at - it a reasonable explanation for this behavior? Have someone at - he found a reliable solution?

    Thanks for help

    Miro

    I received your email

    I saw something strange in the, but then realize that the elimination was logically invalid and created a simple demo.

    If you look at the two surviving tables SEPARATELY it seems reasonable to eliminate the krajina - but when you look at the other two tables at the same time you realize that you have a line in krajina which corresponds to a line in vymenny_urad but not in cennik_090 and a line that does the opposite. In this case, the other two lines survive when you eliminate the krajina, but they disappear if krajina is located in the middle of the join.

    The problem is solved by 11.1.0.7

    Concerning

    Jonathan Lewis

  • Left join with three-table join query

    I am trying to create a query that left me speechless. Most of the query is simple enough, but I have a problem I do not know how to solve.

    Background:
    We have stock stored in i_action.

    We have the attributes available for each type of action. The attributes available for each action are described in shared_action_attribute. Each type of action can have three attributes or none at all.

    We have the values stored for the attributes in i_attribute_value.

    An example says:
    We have a transfer action (action_code B4). The action of B4 entry into i_action records the fact that the transfer took place and the date at which he spoke. The attributes available for a transfer action are the function code receiver, the receiving unit number and the reason of transfer code. These types of attributes available and their order are stored in shared_action_attribute. The actual values of the attributes for a specific action of transfer are stored in i_attribute_value.

    Now i_action and i_attribute_value can be connected directly in action_seq in i_action and ia_action_seq in i_attribute_value. A left join on these two tables provides results for all actions (including actions that have no attributes) and assign values (see Query 1 below).

    There are two questions. First of all, I want only the first two attributes. To specify the attributes of the first two, I also i_attribute_value a link to shared_action_attribute (which is where the order is stored). I can build a simple query (without the left join) which connects the three tables, but then shares without attributes would be excluded from my result (see Query 2 below).

    The second problem is that I'd actually a row returned for each action with first_attribute and second_attribute in the form of columns instead of two lines.

    The final query will be used to create a materialized view.

    Here are the tables and examples of what is stored in the:

    TABLE i_action
    Name Type
    ----
    ACTION_SEQ NUMBER (10)
    DATE OF ACTION_DATE
    ACTION_CODE VARCHAR2 (3)
    VARCHAR2 (1) DELETED

    EXAMPLE OF LINES
    ACTION_SEQ ACTION_DATE DELETED ACTION_CODE
    ----
    45765668 9 OCTOBER 09 B2 HAS
    45765670 9 OCTOBER 09 BA HAS
    45765672 B6 9 OCTOBER 09A
    45765673 9 OCTOBER 09 B4 HAS
    45765674 9 OCTOBER 09 G1 HAS
    45765675 9 OCTOBER 09 M3 HAS

    TABLE i_attribute_value
    Name Type
    ---
    IA_ACTION_SEQ NUMBER (10)
    SACTATT_SACT_CODE VARCHAR2 (3)
    SACTATT_SAT_TYPE VARCHAR2 (3)
    VARCHAR2 VALUE (50)

    EXAMPLE OF LINES
    IA_ACTION_SEQ SACTATT_SACT_CODE SACTATT_SAT_TYPE VALUE
    ----
    45765668 B2 COA 37 B
    45765670 BA ROA D
    45765670 BA ROR P
    45765672 B6 CAT C
    B4 45765673 RFC E
    45765673 B4 TRC P
    B4 45765673 RUN 7
    45765674 G1 SS 23567
    G1 45765674 ASG W

    TABLE shared_action_attribute
    Name Type
    ---
    SACT_CODE VARCHAR2 (3)
    SAT_TYPE VARCHAR2 (3)
    ORDER NUMBER (2)
    TITLE VARCHAR2 (60)

    EXAMPLE OF LINES
    SACT_CODE SAT_TYPE UNDER THE ORDER
    ----
    B2 ACO 1 Office code
    BA ROR 1 reason to re-open
    Authority of BA ROA 2 reopen
    B6 CAT 1 category
    B4 RFC 1 reception function code
    B4 RUN 2 receives the unit code
    B4 TRC 3 transfer of reason code
    Sequence of G1 SS 1 personal
    Reason for G1 ASG 2 assignment

    QUERY 1:
    It's my current query as well as its results. Most are select simple but only one column is filled using the function analytic last_value (thank you guys). The last column in the view sub stores the value of the attribute. What I want is to replace this single column with two columns named first_attribute and second_attribute and eliminate all other attributes.
    SELECT ia.action_seq, ia.action_date, ia.action_code cod,
    NVL
    (LAST_VALUE (CASE
    WHEN ia.action_code = "G1".
    AND iav.sactatt_sat_type = 'SS '.
    THEN THE VALUE
    WHEN ia.action_code IN ('A0', 'A1')
    THEN '67089'
    END IGNORE NULLS
    ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
    IA.serial_number, ia.action_seq),
    '67089'
    ) staff_seq,.
    value
    From i_action LEFT JOIN i_attribute_value iav AI
    ON iav.ia_action_seq = ia.action_seq
    WHERE ia.deleted = 'A ';

    ACTION_SEQ ACTION_DA COD STAFF_SEQ VALUE
    ----
    45765668 9 OCTOBER 09 B2 67089 37 B
    45765670 9 OCTOBER 09 BA D 67089
    45765670 9 OCTOBER 09 BA 67089 P
    45765672 9 OCTOBER 09 B6 67089 C
    45765673 9 OCTOBER 09 B4 67089 E
    45765673 9 OCTOBER 09 B4 67089 P
    45765673 9 OCTOBER 09 67089 7 B4
    45765674 9 OCTOBER 09 23567 23567 G1
    45765674 9 OCTOBER 09 G1 23567 W
    45765675 9 OCTOBER 09 M3 23567

    QUERY 2:
    This query is limited to the first two attributes but he also filed actions which have no attributes, and it creates still several lines for each action instead of a single line with two columns for attributes.
    SELECT ia.action_seq, ia.action_date, ia.action_code cod,
    NVL
    (LAST_VALUE (CASE
    WHEN ia.action_code = "G1".
    AND iav.sactatt_sat_type = 'SS '.
    THEN THE VALUE
    WHEN ia.action_code IN ('A0', 'A1')
    THEN '67089'
    END IGNORE NULLS
    ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
    IA.serial_number, ia.action_seq),
    '67089'
    ) staff_seq,.
    value
    OF shared_action_attribute saa, ims_action AI, ims_attribute_value iav
    WHERE iav.ia_action_seq = ia.action_seq
    AND iav.sactatt_sact_code = saa.sact_code
    AND iav.sactatt_sat_type = saa.sat_type
    AND saa.display_order IN ('1 ', ' 2')
    AND ia.deleted = 'A ';

    ACTION_SEQ ACTION_DA VALUE OF COD
    ----
    45765668 9 OCTOBER 09 B2 67089 37 B
    45765670 9 OCTOBER 09 BA D 67089
    45765670 9 OCTOBER 09 BA 67089 P
    45765672 9 OCTOBER 09 B6 67089 C
    45765673 9 OCTOBER 09 B4 67089 E
    45765673 9 OCTOBER 09 67089 7 B4
    45765674 9 OCTOBER 09 23567 23567 G1
    45765674 9 OCTOBER 09 G1 23567 W

    I found it quite complex to try to write - I hope that I was clear.

    Thank you very much!

    Hello

    You can use an alias for column (such as staff_seq) in the ORDER BY. Unfortunately, it's the only place where you can use it in the same query, where it was defined.
    You can use it anywhere in the super-requetes, however, so you can still work around this problem in assigning the aliases in a subquery and GROUP BY (or other) in a Super query, like this:

    WITH   ungrouped_data      AS
    (
        SELECT ia.action_seq, ia.action_date, ia.action_code,
              NVL
                  (LAST_VALUE (CASE
                                  WHEN ia.action_code = 'G1'
                                   AND sactatt_sat_type = 'SS'
                                     THEN VALUE
                                  WHEN ia.action_code IN ('A0', 'A1')
                                     THEN '67089'
                               END IGNORE NULLS
                              ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date, ia.action_seq),
                   '67089'
                  )staff_seq,
               (CASE
                  WHEN display_order = '1'
                  THEN VALUE
               END) first_attribute,
               (CASE
                  WHEN display_order = '2'
                  THEN VALUE
               END) second_attribute
          FROM i_action ia
          LEFT JOIN i_attribute_value iav
               ON iav.ia_action_seq = ia.action_seq
          LEFT JOIN shared_action_attribute
               ON sactatt_sact_code = sact_code
             AND sactatt_sat_type = sat_type
         WHERE ia.deleted = 'A'
    )
    SELECT       action_seq
    ,       action_date
    ,       action_code
    ,       staff_seq
    ,       MIN (first_attribute)          AS first_attribute
    ,       MIN (second_attribute)     AS second_attribute
    FROM       ungrouped_data
    GROUP BY  action_seq
    ,       action_date
    ,       action_code
    ,       staff_seq
    ;
    

    There are other alternatives for special cases, but none of them work in this particular case.

  • To create an interactive report in the apex by selecting from multiple tables

    Hi, I am creating an interactive report by selecting from multiple tables.

    SELECT w.FIRST_NAME as name, w.SURNAME as name, i.ROAD Road, i.DATE_OF_INC as DATE_OF_INC, S.STATEMENT as a STATEMENT OF Declaration

    JOIN THE

    WITNESS w

    ON w.witness_id = s.FK1_WITNESS_ID

    JOIN THE

    Incident I have

    WE

    i.incident_no = w.FK1_INCIDENT_NO

    JOIN THE

    user_station ps

    ON ps.station_id = i.nearest_station_id

    JOIN THE

    the user in.

    WE

    in. STATION_ID = ps.station_id

    WHERE po.officer_id = 1

    by I continue to encounter this error "the report query requires a unique key to identify each row. The supplied key cannot be used for this query. Please change the report attributes to define a unique key column. "ORA-01445: cannot select ROWID from where sample, a join without key preserved table view '

    So I googled around and found that in the attibutres tables report, I need to change the "LINK" COLUMN so first, I changed "Link to custom target", but the report is so I changed it to "Exclude link Clolumn" again, the report didn't report and I STILL got a blank page with only the tabs.

    I wonder you can not create a report by selecting from multiple tables?

    If you can please I need your help.

    Thank you

    You can, but in this case, it might be easier to build your report tables that are joined Oracle views and then build your report out of the newly built sight...

    Or wrap a selection around your selection with joins, and then make the where clause on the external selection...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • Update multiple columns from multiple tables in a single UPDATE request

    Hello

    I'm trying to figure if I'm heading in the right direction.

    I want to update multiple columns from multiple tables in a single UPDATE request. Also, I would like to update multiple columns in a table from the tables.

    Scenario 1

    UPDATE Table2, Table 3
    SET T2.Column1 = T1.Column1 
    ,T2.Column2 = T1.Column2
    ,T3.Column2 = T1.Column2
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T1.id = T2.id
    and T1.id = T3.id
    
    

    Scenario 2

    UPDATE Table3
    SET T3.Column1 = T1.Column1 
    T3.Column2 = T1.Column2
    ,T3.Column3 = T2.Column3
    ,T3.Column4 = T2.Column4
    FROM Table1 T1, Table2 T2, Table3 T3
    WHERE T3.id = T1.id
    and T3.id = T2.id
    
    

    Hello

    For scenario 1, you must write separate instructions UPDATE table2 and table3.

    To guard against someone else change one of these tables while you act so you can copy all relevant data in a global temporary table and update this global temporary table table3.

    ENGAGE only when two tables have been changed.

    You can write a procedure or an INSTEAD OF trigger to do all this.

    For scenario 2, you can reference many tables that you need when new table3.  It might be more efficient and simpler to use the MERGER rather than UPDATED.  For example:

    MERGE INTO table3 dst

    WITH THE HELP OF)

    SELECT t1.id

    t1.column1

    t1.column2

    t2.column3

    t2.column4

    FROM table1 t1

    JOIN table2 t2 ON t1.id = t2.id

    )             src

    WE (dst.id = src_id

    WHEN MATCHED THEN UPDATE

    SET dst.column1 = src.column1

    dst.column2 = src.column2,

    dst.column3 = src.column3,

    dst.column4 = src.column4,

    ;

  • data in multiple tables and columns

    Hello

    How to find if multiple tables are containing the same data?
    Text of the 'Apple' is in three different tables and under three different column names.
    Expected result
     
    fruits_one
    fruits_two 
    fruits_three
    Select name, quantity from fruits_one;
    Apple   1
    Orange  1
    Pear    1
    
    
    select flavour, desc from fruits_two;
    Red,   Apple 
    Blue, Berry
    
    select order,date,details  from fruits_three;
    101  11/11/2011    Grapes
    102  12/01/2010    Apple
    Thank you
    Sandy
    SQL> create table fruits_one (name varchar2(100), quantity number);
    
    Table created.
    
    SQL> insert into fruits_one
      2  select 'Apple'  name, 1 quantity from dual union all
      3  select 'orange'  name, 1 quantity from dual; 
    
    2 rows created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> create table fruits_two (flavour varchar2(100), des varchar2(100));
    
    Table created.
    
    SQL> insert into fruits_two
      2  select 'Red' flavour,   'Apple' des  from dual union all
      3  select 'blue' , 'berry'  from dual ;
    
    2 rows created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> set serveroutput on
    SQL> declare
      2  l_search varchar2(10) := 'APPLE';
      3  l_cnt number := 0;
      4  begin
      5
      6  for x in (select column_name, data_type, table_name from user_tab_cols where data_type in ('VAR
    CHAR2'))
      7  loop
      8
      9    execute immediate  'select count(*) from "' || x.table_name ||'" where upper("' || x.column_n
    ame || '") like ''%' || l_search || '%''' into l_cnt;
     10
     11    if l_cnt > 0  then
     12    dbms_output.put_line('table = "' || x.table_name ||'", column = "' || x.column_name ||'"');
     13    end if;
     14
     15  end loop;
     16
     17  end;
     18  /
    table = "FRUITS_ONE", column = "NAME"
    table = "FRUITS_TWO", column = "DES"
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • cannot find the table name of the multiple tables which has more columns.

    Hello

    I'm trying to find the NAME of the TABLE from multiple tables which has more columns. I can't count the number of columns in the table, but cannot find the name of the table that has larger columns in other tables.

    SELECT TABLE_NAME, COUNT (*) FROM THE USER_TAB_COLUMNS WHERE TABLE_NAME LIKE '% LOC' GROUP TABLE_NAME


    Thank you.

    in SQL, you can try this:

    var v_name varchar2(40)
    
    begin
       with
          subq1 as ( select table_name, count(*) as column_count from user_tab_columns where table_name like 'FIBER%'
                         group by table_name
                         order by count(*) desc )
       select table_name
         into :v_name
        from subq1
       where rownum = 1;
    end;
    

    To get the result:

    select :v_name from dual
    

    The clause "with" brings together all the tables and ordered them all first, by the greatest number of columns
    The final query uses the rownum restriction so that it takes the first name from the table of results of the subquery.

    The restriction of rownum also exactly guarantees a result each time so that it will work with the variable binding.

    RP

  • Create record in the Table of results gives error

    Hi all

    Update page there is a table of results with the Add button to create a new line.

    Everything by creating a new record on the table of results gives an error

    The attributes defined for AccessId in the view object xxlcupdvariablesvo1 failed

    I checked the EO and VO attributes, everything seems to be good.
    Updatable also has the value "Always".


    Still don't know why this error is coming.

    Please help resolve this error.


    Thank you
    SK

    SK

    Don't forget that your AO made correctly and you do your from VO of the two OS after this AO. If possible, allow Jdev to create your AO. Try to create is not in manuallly

    Hope it solves your problem

    Thank you
    AJ

  • Tree of SQL on multiple tables

    Hi gurus,

    I have a question about the trees of building sql on multiple tables.

    It's the exit, I hope:
    0
    - 10, 'Company Blue1', 0
    -- 101, 'Part Blue1', 10
    --- 1001, 'Accounting Blue', 101
    ---- 10001, 'Hans Mueller', 1001
    --- 1002, 'Special Problems Blue', 101 
    ---- 10002, 'Stephen Meyer', 1002
    ---- 10003, 'Carlos Anceto', 1002
    -- 102, 'Part Blue2', 10
    --- 1003, 'Information Technology Blue', 102
    ---- 10004, 'Tobias Tries', 1003
    - 20, 'Company Red1', 0
    -- 201, 'Part Red1', 20
    --- 2001, 'Accounting Red', 201
    ---- 20001, 'Carl Van Deser', 2001
    ---- 20002, 'Geromel Boats', 2002
    - 30, 'Company Green1', 0
    -- 301, 'Part Green1', 30
    --- 3001, 'Accounting Green', 301
    ---- 30002, 'Peter Finnighan', 3001
    --- 3003, 'Special Problems Green', 301
    ---- 30001, 'Loui Van Ecke', 3003
    This is the situation: I have 4 table which can be forced to key foreign and all build toghether in a tree.
    Table1:
    tbl_company (c_id, company_name)
    Values: 
    10, 'Company Blue1'
    20, 'Company Red1'
    30, 'Company Green1'
    
    Table2:
    tbl_company_parts (cp_id, part_name, company_id)
    Values: 
    101, 'Part Blue1', 10
    102, 'Part Blue2', 10
    201, 'Part Red1',20
    301, 'Part Green1',30
    
    Table3:
    tbl_departments (d_id, dept_name, part_id)
    Values: 
    1, 'Accounting Blue', 101
    2, 'Special Problems Blue', 101
    3, 'Information Technology Blue', 102
    4, 'Accounting Red',201
    5, 'Accounting Green',301
    6, 'Special Problems Green',301
    
    Tablemployees (e_id, dept_name, department_id)
    Values: 
    1, 'Hans Mueller', 1
    2, 'Stephen Meyer', 2
    3, 'Carlos AncetoÄ, 2
    4, 'Carl Van Deser',4
    5, 'Geromel Boats', 4
    6, 'Loui Van Ecke',5
    7, 'Peter Finnighan',6
    8, 'Tobias Tries',3
    The problem is that I do not know how in alle concate these values and using the connection by the clause that creates this tree

    Hi Tobias,.

    It was not exactly how id should be calculated, but this example you get:

    SQL> create table tbl_company (c_id, company_name)
      2  as
      3  select 10, 'Company Blue1' from dual union all
      4  select 20, 'Company Red1' from dual union all
      5  select 30, 'Company Green1' from dual
      6  /
    
    Table created.
    
    SQL> create table tbl_company_parts (cp_id, part_name, company_id)
      2  as
      3  select 101, 'Part Blue1', 10 from dual union all
      4  select 102, 'Part Blue2', 10 from dual union all
      5  select 201, 'Part Red1',20 from dual union all
      6  select 301, 'Part Green1',30 from dual
      7  /
    
    Table created.
    
    SQL> create table tbl_departments (d_id, dept_name, part_id)
      2  as
      3  select 1, 'Accounting Blue', 101 from dual union all
      4  select 2, 'Special Problems Blue', 101 from dual union all
      5  select 3, 'Information Technology Blue', 102 from dual union all
      6  select 4, 'Accounting Red',201 from dual union all
      7  select 5, 'Accounting Green',301 from dual union all
      8  select 6, 'Special Problems Green',301 from dual
      9  /
    
    Table created.
    
    SQL> create table tbl_employees (e_id, emp_name, department_id)
      2  as
      3  select 1, 'Hans Mueller', 1 from dual union all
      4  select 2, 'Stephen Meyer', 2 from dual union all
      5  select 3, 'Carlos Anceto', 2 from dual union all
      6  select 4, 'Carl Van Deser',4 from dual union all
      7  select 5, 'Geromel Boats', 4 from dual union all
      8  select 6, 'Loui Van Ecke',5 from dual union all
      9  select 7, 'Peter Finnighan',6 from dual union all
     10  select 8, 'Tobias Tries',3 from dual
     11  /
    
    Table created.
    
    SQL> select coalesce
      2         ( case when e.department_id is null then null else
      3             trunc(d.part_id,-2) * 100 + dense_rank() over (partition by d.part_id order by e.e_id)
      4           end
      5         , trunc(d.part_id,-2) * 10 + dense_rank() over (partition by d.part_id order by d.d_id)
      6         , p.cp_id
      7         , c.c_id
      8         , 0
      9         ) id
     10       , coalesce
     11         ( e.emp_name
     12         , d.dept_name
     13         , p.part_name
     14         , c.company_name
     15         ) name
     16       , coalesce
     17         ( trunc(d.part_id,-2) * 10 + dense_rank() over (partition by d.part_id order by d.d_id)
     18         , d.part_id
     19         , p.company_id
     20         , case grouping(c.c_id) when 0 then 0 end
     21         ) parent_id
     22    from tbl_company c
     23       , tbl_company_parts p
     24       , tbl_departments d
     25       , tbl_employees e
     26   where c.c_id = p.company_id
     27     and p.cp_id = d.part_id
     28     and d.d_id = e.department_id
     29   group by rollup
     30         ( ( c.c_id,c.company_name)
     31         , ( p.cp_id,p.part_name,p.company_id)
     32         , ( d.d_id,d.dept_name,d.part_id)
     33         , ( e.e_id,e.emp_name,e.department_id)
     34         )
     35   order by c.c_id nulls first
     36       , p.cp_id nulls first
     37       , d.d_id nulls first
     38       , e.e_id nulls first
     39  /
    
            ID NAME                                                                               PARENT_ID
    ---------- --------------------------------------------------------------------------------- ----------
             0
            10 Company Blue1                                                                              0
           101 Part Blue1                                                                                10
          1001 Accounting Blue                                                                         1001
         10001 Hans Mueller                                                                            1001
          1002 Special Problems Blue                                                                   1002
         10002 Stephen Meyer                                                                           1002
         10003 Carlos Anceto                                                                           1002
           102 Part Blue2                                                                                10
          1001 Information Technology Blue                                                             1001
         10001 Tobias Tries                                                                            1001
            20 Company Red1                                                                               0
           201 Part Red1                                                                                 20
          2001 Accounting Red                                                                          2001
         20001 Carl Van Deser                                                                          2001
         20002 Geromel Boats                                                                           2001
            30 Company Green1                                                                             0
           301 Part Green1                                                                               30
          3001 Accounting Green                                                                        3001
         30001 Loui Van Ecke                                                                           3001
          3002 Special Problems Green                                                                  3002
         30002 Peter Finnighan                                                                         3002
    
    22 rows selected.
    

    Kind regards
    Rob.

  • Query with multiple Tables

    Hello

    I want to run the table several queries. I have 4 tables. Table 1 is to have relatively in table 2, but table 3 & 4 is not related with table 1. wherever I want to extract the data from table 1, table 4. My current query works well but it miss the Chronogram of table 1, which records do not exist in table 2, where, from table 2 of table 4 its working fine.

    SELECT z.productcode, fabqty z.productionadviceno, sum (z.fabricatedqty).

    Fabqtynoms Round (Sum(z.fabricatedqty*.015) + Sum (z.fabricatedqty)),

    w.workorderno, ons min (w.ons).

    ((SOMME (w.qtyinsheets) * min (ons))) PCS,

    (SELECT SUM (NVL (mrnqty, 0)))

    OF CANMRN

    WHERE workorderno = w.workorderno) mrnqty;

    (SELECT ROUND (SUM (NVL (ptnqty, 0))))

    OF CANPTN

    WHERE workorderno = w.workorderno

    ) ptnqty

    OF CANWORKORDER w, productionadvice z

    where w.productionadviceno = z.productionadviceno

    and w.productcode = 501001

    GROUP BY w.workorderno, z.productionadviceno, z.productcode

    PRODUCTCODE PRODUCTIONADVICENO FABQTY FABQTYNOMS WORKORDERNO ONS SCP MRNQTY PTNQTY

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

    501001 20004182 250000 253750 20001805 15 253755 16917 253755

    501001 20004229 200000 203000 20001817 15 202995 13533 202995

    501001 20004251 130000 131950 20001829 15 131955 8797 131955

    501001 20004256 200000 203000 20001839 15 202995 13533 202995

    501001 20004277 500000 507500 20001844 15 507495 33833 507495

    501001 20004411 500000 507500 20001918 15 507495 31619 474285

    501001 20004904 230000 233450 20002150 15 233445

    I want to get this record also is missing after you run the query, as I had mentioned w.productionadviceno = z.productionadviceno due to which its does not, how, in a delicate way, we can use this relationship.

    501001 20004905 10000 10150

    Sandy

    use of EXTERNAL JOINS as follows

    where w.productionadviceno = z.productionadviceno (+)
    

    above is a left outer join. A LEFT OUTER JOIN is a JOIN operations that allow you to specify a join clause. He keeps the lines without correspondence of the first (left) table, join them with a NULL row in the form of the second table (right).

    More details: LEFT OUTER JOIN operation

  • Use with need to collect in bulk to insert records from multiple tables

    Hello

    I plsql record type with several tables with multiple columns. so when I used bulk collect with education for ALL. I want to insert records in multiple tables.

    Please give me suggestions.

    ForAll is designed to be used with a single DML statement, which may include dynamic SQL statements. However, I do not know what advantage this will give you your list iteration save several times, one for each table - especially since there is an air show with SQL dynamic.

    Example 1 (dynamic SQL):

    begin

      ...

      forall i in vRecList.First..vRecList.Last
        execute immediate '
        begin
          insert into Table1 (Col1, Col2, Col3) values (:1, :2, :3);
          insert into Table2 (Col1, Col2, Col3) values (:1, :2, :3);
        end;' using vRecList(i).Col1, vRecList(i).Col2, vRecList(i).Col3;
    end;

    Another approach that I should work (but not tested) is using to insert all the Scriptures and based record inserts, but you need to try on your version of Oracle forall has changed between the versions.  In this case vRecList must be compatible with the Table % ROWTYPE and Table2% ROWTYPE type.


    Example 2 (insert all):

    begin

      ...

      forall i in vRecList.First..vRecList.Last

        insert all

          into Table1 values vRecList(i)
          into Table2 values vRecList(i)
        select 1 from dual;

    end;

  • Images in the table of results

    ImageInResultsTable.JPG

    Hello

    I use latitude short 2.2.2 studio and I have many results in the application.

    There is a table of results, where I have the image as the value of the cell (see as steep as above - second column with a small img)

    I want to resize the height and width for only this instance of the results table.

    How can I achieve this?

    Thanks in advance for the answers.

    Hello

    "You pass the value of the image as http://pathtoimage/name.png" width = "150" height = "150" > '?

    Short Studio 2.2 has no image support. But little CSS trick can work.

    Comment out the following line in tomcat-6.0.29\webapps\ROOT\html\extjs\endeca-extjs-overrides.css

    max height: 11px; / * same size as the text in the grid * /.

    Note: This may alter the alignment.

  • Select Max (date) between multiple tables

    I need to retrieve a record from a Table in a set of similar tables with a common "date field". You can select the record where this "date field" value is greater between multiple tables.

    Here, any help is appreciated.  Thank you in advance.

    FOR EXAMPLE

    No. EMP is the primary key.

    Again, each table can have multiple records for EMP n ° 1

    TABLE1:

    FIRST NAME

    FAMILY NAME
    THE EMP NO.

    BASE SALARY

    DATE_FROM

    TABLE 2

    FIRST NAME

    FAMILY NAME
    THE EMP NO.

    SALARY GRADE

    DATE_FROM

    TABLE 3

    FIRST NAME

    FAMILY NAME
    THE EMP NO.

    COMPENSATION

    DATE_FROM

    Hello

    Said Knani, if you use the current design of the table, then here is a way to do what you want:

    WITH union_data AS

    (

    SELECT MAX (base_salary) AS sal FROM table1 UNION ALL

    SELECT MAX (grade_salary) table2 UNION ALL

    SELECT MAX (compensation) FROM table3

    )

    SELECT MAX (sal) AS max_sal

    Of union_data

    ;

Maybe you are looking for