cunning as query clause

Hello
Test table)
integer ID,
col1 varchar2 (50)
)
data in the table:
ID col1
1 ab, abc
2 abc
3 cd

How can I recover the data table that contains string "ab" in col1. Here, 'abc' is very good. the values are stored with demiliter decimal. order of the values is not guaranteed as ab, ab or abc, abc.
from the example above, I would like to see documents with iid 2.3 in the output. I thought about it using like clause. found no medium.

Thanks for the help.

Another solution

var p varchar2(10);
exec :p:='ab';
WITH TEST AS
     (SELECT 1 ID, 'ab,abc' col1
        FROM DUAL
      UNION ALL
      SELECT 2, 'abc'
        FROM DUAL
      UNION ALL
      SELECT 3, 'cd'
        FROM DUAL)
SELECT ID, col1
  FROM test
WHERE ','|| col1 ||',' not like  '%,'||:p||',%';
SQL> var p varchar2(10);
SQL> exec :p:='ab';

Procédure PL/SQL terminée avec succès.

SQL> WITH TEST AS
  2       (SELECT 1 ID, 'ab,abc' col1
  3          FROM DUAL
  4        UNION ALL
  5        SELECT 2, 'abc'
  6          FROM DUAL
  7        UNION ALL
  8        SELECT 3, 'cd'
  9          FROM DUAL)
 10  SELECT ID, col1
 11    FROM test
 12  WHERE ','|| col1 ||',' not like  '%,'||:p||',%';

        ID COL1
---------- ------
         2 abc
         3 cd

SQL> 
SQL> var p varchar2(10);
SQL> exec :p:='ab';

Procédure PL/SQL terminée avec succès.

SQL> WITH TEST AS
  2       (SELECT 1 ID, 'ab,abc' col1
  3          FROM DUAL
  4        UNION ALL
  5        SELECT 2, 'abc'
  6          FROM DUAL
  7        UNION ALL
  8        SELECT 3, 'cd'
  9          FROM DUAL)
 10  SELECT ID, col1
 11    FROM test
 12  WHERE INSTR (','|| col1 ||',', ','||:p||',') = 0;

        ID COL1
---------- ------
         2 abc
         3 cd

SQL> 

Tags: Database

Similar Questions

  • Query clause ignores to export records

    Hi all;

    I am trying to export a few records from table but query clause the customer the throwing error.

    SCOTT > customer desc

    Name                                      Null?    Type

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

    NUMBER OF CUST_ID

    CUST_NAME VARCHAR2 (15)

    VARCHAR2 (15) REGION

    NUMBER OF CUST_CREDIT_LIMIT

    $ expdp System/Manager dumpfile = dp:1.dmp tables = scott.customers query = scott. "CUSTOMERS:" where exists (select cust_id from CUSTOMERS c where cust_credit_limit > 12400 and ku$ .cust_id = c.sust_id) "" reuse_dumpfiles = yes

    Export: Release 11.2.0.1.0 - Production on Fri Aug 7 17:11:32 2015

    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

    With partitioning, OLAP, Data Mining and Real Application Testing options

    Start "SYSTEM". "" SYS_EXPORT_TABLE_01 ": System / * dumpfile = dp:1.dmp tables = scott.customers query = scott. CUSTOMERS: "where exists (select cust_id from CUSTOMERS c where cust_credit_limit > 12400 and ku$ .cust_id = c.sust_id)" reuse_dumpfiles = yes "

    Current estimation using BLOCKS method...

    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

    Total estimation using BLOCKS method: 64 KB

    Object type TABLE_EXPORT/TABLE/TABLE processing

    ORA-31693: Table object data 'SCOTT '. "' CUSTOMERS ' could not load/unload and being ignored because of the error:

    ORA-00942: table or view does not exist

    Main table 'SYSTEM '. "" SYS_EXPORT_TABLE_01 "properly load/unloaded

    ******************************************************************************

    Empty the file system set. SYS_EXPORT_TABLE_01 is:

    /U01/DataPump/1.dmp

    Work 'SYSTEM '. "" SYS_EXPORT_TABLE_01 "completed with error (s 1) at 17:11:50

    Hello

    I think the problem is that you run the job as system by default, all object references are to the system, you need to change

    $ expdp System/Manager dumpfile = dp:1.dmp tables = scott.customers query = scott. "CUSTOMERS:" where exists (select cust_id from CUSTOMERS c where cust_credit_limit > 12400 and ku$ .cust_id = c.sust_id) "" reuse_dumpfiles = yes

    TO

    $ expdp System/Manager dumpfile = dp:1.dmp tables = scott.customers query = scott. "CUSTOMERS:" where exists (select cust_id scott. CUSTOMER c where cust_credit_limit > 12400 and ku$ .cust_id = c.sust_id) "" reuse_dumpfiles = yes

    I also recommend that you use one parfile to avoid problems of interpretation of the characters by the shell

    See you soon,.

    Rich

  • block based query clause

    Hi all...

    I use form 10g...
    When I tried the query clause from block...
    I used this query (SELECT * FROM exit INNER JOIN enter ON exit.ent_num = enter.ent_num where to enter departure = 1)...
    When I run the form...
    error frm-40505 oracle unable to execute the query

    Thank you

    Published by: osa3_12 on December 10, 2009 04:33

    Hello

    I think that you are joining two tables which have duplicate column names... In this case you must give the name of different aliases for the similar columns... You cannot use select *...

    Should be selected enter.ent_num enter_ent_num, exit.ent_num exit_ent_num...

    concerning
    Dora

  • JDeveloper does not support the SQL expert, cannot add query clause to view link

    For developers who can know:

    I use JDeveloper 10.1.3.4 and I have two tables, we're STUDENTS, the other is the PRICE, with a one-to-many relationship (a student may have several awards), and ID is the foreign key:
    STUDENTS
    ------------------------
    ID    NAME    DOB
    ------------------------
    9999  JOHN    01/02/1990
       |  
       |  
       |  
       |           AWARDS
       |           ------------------------
       |           ID      DESC      AMOUNT
       |           ------------------------
       ----------- 9999    PELL      500
                   9999    PERKINS   800
                   9999    LOAN      900
    In the application, when a student (9999, JOHN) connects, the information above is displayed. I need to add up all the awards for the student and to display not only the elements of price, but also the total amount of all awards. To do this, I created another object to view named TotalAwards in the object entity the price just to get the total amount. The SQL code of the VO's
    SELECT SUM(Awards.AMOUNT) AS TOTAL
    FROM AWARDS Awards
    Then, a link is created between the students and the TotalAwards, and use of the new link to the view is added to the application module. TotalAwards is now available in the data control palette to be drag-and - drop to pages.

    Problem occurs when the application is invoked. An error is caught before the application can begin. The error message indicates that "the ends or the link view do not specify an attribute.

    It seems that the TOTAL 'SUM (Awards.AMOUNT) AS TOTAL' is not recognized as an attribute. I have reviewed the query clause in the display link to see if it is there, such as:
             Attribute        Bind Variable
             ------------     --------------
             Students.ID      :Bind_Id
    
    
    WHEHE    :Bind_Id = Awards.ID
    There is no such clause in the query clause page. And I can not add a no more, because the page is grayed out and disabled. I think maybe it's for the same reason: TOTAL is not recognized as an attribute of the price.

    How to get around the problem? Or are there other ways to summarize the total amount and view it in the browser?

    Thank you very much for help!


    Newman

    Hello

    Here you have a solution for the TOTAL:
    http://www.freewebalbum.com/blogs/faces/bjanko/blogs.jsp?blog=bjanko20070725180020

    Kind regards

    Branislav

  • Query clause

    Hello

    I use this query in a from clause

    SELECT PM.PATIENT_FILE_NO,
           PE.EPISODE_NO,
           DECODE(CURRENT_LANG_P_S,
                  'P',
                  PATIENT_NAME_P || ' ' || PATIENT_NAME_2_P || ' ' ||
                  PATIENT_NAME_3_P || ' ' || PATIENT_NAME_F_P,
                  PATIENT_NAME_S || ' ' || PATIENT_NAME_2_S || ' ' ||
                  PATIENT_NAME_3_S || ' ' || PATIENT_NAME_F_S) PATIENT_NAME,
           PE.START_DATE,
           PE.END_DATE,
           EXSYS.GET_AGE(PM.DATE_OF_BIRTH) AGE,
           CODES_PKG.GET_DESCRIPTION(PM.GENDER, 103) GENDER,
           PE.ATTENDANCE_TYPE,
           PATIENT_CATEGORY
      FROM RC_PATIENTS PM, RC_PATIENT_EPISODES PE
     WHERE PM.PATIENT_FILE_NO = PE.PATIENT_FILE_NO
       AND PE.STATUS != 'C'
    
    

    The query works in "pl/sql Developer", but when I run the form I had 'query caused no records to retrieve.

    -I wrote

    go_block ('block_name');

    execute_query;

    in a trigger w-n-f-i

    -J' have elements compatible with the number and names of the collected columns of the query, but I have more elements in the same block

    ??

    I found it, thanks

    There are certain triggers prevent execution of code

    Thank you

  • Rewriting query clause error

    Hi all;

    I did not finish the rewrite of the query (M.view) clause, trying to activate I get the error message
    and I asked this question "https://forums.oracle.com/forums/thread.jspa?threadID=2543789".
    Question incorrectly displayed data communication model. -If this isn't a duplicate thread.

    Please answer me what was missing here?

    SQL > alter system set query_rewrite_enabled = 'TRUE' scope = SPFILE;
    SQL > grant query rewrite in *;
    Grant succeeded.
    conn xxx/xxxx@xxxxxx
    1 SQL > ALTER SESSION SET OPTIMIZER_MODE = FIRST_ROWS.
    Altered session.
    2 SQL > alter session set query_rewrite_enabled = true;
    Altered session.
    3 SQL > execute dbms_stats.gather_table_stats ('rose', 'mv1');
    PL/SQL procedure successfully completed.
    4 SQL > exec dbms_mview.explain_rewrite ("select * sales ', but 'MV1'");
    BEGIN dbms_mview.explain_rewrite ("select from sales, 'MV1'"); END; *
    * ERROR at line 1:
    ORA-30380: REWRITE_TABLE does not exist
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 3085
    ORA-06512: at "SYS." DBMS_SNAPSHOT", line 3206
    ORA-06512: at line 1
    thanks in advance...

    Hello

    Run utlxrw.sql to create the table.

    concerning

  • [10g] need help with order by hierarchical query clause

    I have the following data samples:
    CREATE TABLE     bill_test1
    (     parent_part     CHAR(25)
    ,     child_part     CHAR(25)
    ,     line_nbr     NUMBER(5)
    ,     qty_per          NUMBER(9,5)
    );
    
    INSERT INTO bill_test1 VALUES ('ABC-1','ABC-10',100,1);
    INSERT INTO bill_test1 VALUES ('ABC-1','ABC-20',200,2);
    INSERT INTO bill_test1 VALUES ('ABC-1','ABC-30',300,3);
    INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-1',401,10);
    INSERT INTO bill_test1 VALUES ('ABC-1','HARDWARE-2',402,5);
    INSERT INTO bill_test1 VALUES ('ABC-10','ABC-155',100,2);
    INSERT INTO bill_test1 VALUES ('ABC-10','HARDWARE-1',200,1);
    INSERT INTO bill_test1 VALUES ('ABC-155','RAW-2',100,4.8);
    INSERT INTO bill_test1 VALUES ('ABC-155','HARDWARE-3',200,3);
    INSERT INTO bill_test1 VALUES ('ABC-20','RAW-1',100,10.2);
    INSERT INTO bill_test1 VALUES ('ABC-30','RAW-3',100,3);
    And the following query gives me exactly what I want, in the order I want. However, I wonder if there is a way to get this order without creating the column SEQ, given that I don't need in my results
    SELECT     part_nbr
    ,     parent_part
    ,     child_part
    FROM     (
         SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
         ,     b.parent_part
         ,     b.child_part
         ,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
         FROM     bill_test1 b
         ,     dual
         CONNECT BY     parent_part     = PRIOR child_part
         )
    WHERE          part_nbr     = 'ABC-1'
    ORDER BY     seq
    ;
    
    Results of above query, except with SEQ included in SELECT (just to show what I'm sorting off of):
    PART_NBR                     PARENT_PART                  CHILD_PART                   SEQ
    ---------------------------- ---------------------------- ---------------------------- -----------------
    ABC-1                        ABC-1                        ABC-10                        100
    ABC-1                        ABC-10                       ABC-155                       100 100
    ABC-1                        ABC-155                      RAW-2                         100 100 100
    ABC-1                        ABC-155                      HARDWARE-3                    100 100 200
    ABC-1                        ABC-10                       HARDWARE-1                    100 200
    ABC-1                        ABC-1                        ABC-20                        200
    ABC-1                        ABC-20                       RAW-1                         200 100
    ABC-1                        ABC-1                        ABC-30                        300
    ABC-1                        ABC-30                       RAW-3                         300 100
    ABC-1                        ABC-1                        HARDWARE-1                    401
    ABC-1                        ABC-1                        HARDWARE-2                    402

    Hello

    As long as there is that a single root, brothers and SŒURS of ORDER BY, you say, but you can not do in a subquery (well, you can, but usually there is no interest in a subquery). If the CONNECT BY in a subquery, there is no guarantee that the main request will preserve the hierarchical order which provides the subquery.

    The query you posted does not require a query of Tahina, so you can say:

    SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
    ,     b.parent_part
    ,     b.child_part
    --,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
    FROM     bill_test1 b
    WHERE          CONNECT_BY_ROOT b.parent_part     = 'ABC-1'
    CONNECT BY     parent_part     = PRIOR child_part
    ORDER SIBLINGS BY     b.line_nbr
    ;
    

    I said the query you posted does not require a subquery. It also does not require double, so I guess that what you posted is a simplification of what you are really doing, and that could have a subquery. In particular, if you want to GROUP BY part_nbr, you need the subquery. We can use CONNECT_BY_ROOT expression in the WHERE clause (or, come to think of it, use a START WITH clause instead WHERE), but, for some reason, we cannot use CONNECT_BY_ROOT in a clause GROUP BY; We need to calculate CONNECT_BY_ROOT in a subquery, give it a name (like part_nbr) and Super GROUP OF this column in a query.

    This requires that there is that one node root. ORDER OF brothers and SŒURS means just that: children of a common parent will appear in the order, but the root nodes, which have no parents, may not be in order.

    Here's what I meant by using START WITH place WHERE:

    SELECT     CONNECT_BY_ROOT b.parent_part                         AS part_nbr
    ,     b.parent_part
    ,     b.child_part
    --,     SYS_CONNECT_BY_PATH(b.line_nbr,' ')                    AS seq
    FROM     bill_test1 b
    START WITH     b.parent_part     = 'ABC-1'
    CONNECT BY     parent_part     = PRIOR child_part
    ORDER SIBLINGS BY     b.line_nbr
    ;
    

    This should be much more effective, because it reduces the results before waste you your time by getting their descendants.
    With the help of a clause START WITH here is analogous to me sending you an email, saying "come to a meeting one my office at 03:00."
    By using a WHERE clause here is similar by sending me an e-mail to all members of society, saying: "come to a meeting one my office at 3:00" and then, as people get here, tell everyone except you could go back.

    Brothers and SŒURS ORDER BY was introduced in Oracle 9.

    Published by: Frank Kulash, December 9, 2010 14:39
    Added version with the START WITH clause

  • How to use 'with query clause"in DBadapter

    Hi all
    I need to implement a query "with clause" in oracle soa 11g bpel. When I put the query in the db adapter in pure sql, the schema is not generated correctly. The one you suggest a solution to my problem.

    Kind regards
    Kone

    Pure SQL will not work because it expects the first word in the SQL to SELECT (or INSERT, UPDATE, DELETE).

    If your query is WITH... SELECT...

    Try this:

    Delete everything before SELECTING. Copy and paste the XSD generated to another window. The SQL test may fail, but it simply means that he could not fill the column types in the SELECTION... OF the list. You can always make yourself manually edit the XSD (including in the wizard until you hit then). Then replace the WITH... remaining clause before SELECT it... If the XSD is crushed, the version that you saved in the other window and paste it over. Then press next and the runtime must still work.

    Keep in mind that SQL is very complex and difficult to scan entirely in the user interface. However, the minimum information needs DbAdapter is very limited; basically just the name and number of the columns that are returned. The XSD is supposed to be editable in the wizard, if the SQL code is too complex.

    Thank you

    Steve

  • Order of query clause

    Hello
    Here's the example query.
    with t1 as)
    Select 1 as id, 'aa' as the name of double
    Union
    Select 2, 'a2' of the double
    Union
    Select 3, 'qe' from dual
    Union
    Select option 4, 'ee' from dual
    Union
    Select 5, are ' double
    Union
    Select 6, 'tt' from dual
    Union
    Select 8, 'kl' double)
    SELECT id, name from t1 where id in (6,2,12,5,1)

    the result obtained

    ID NA
    ---------- --
    1 aa
    2 a2
    5 re
    TT 6

    But I need results in order (as in the values clause ic (6,2,12,5,1))
    ID NA
    ---------- --
    TT 6
    2 a2
    5 re
    1 aa

    Is this possible?

    Thank you
    Sujnan

    You can, but you'll need to duplicate the data in the clause of a DECODING (or CASE) statement IN

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t1 as (
      2  select 1 as id, 'aa' as name from dual
      3  union
      4  select 2, 'a2' from dual
      5  union
      6  select 3, 'qe' from dual
      7  union
      8  select 4, 'ee' from dual
      9  union
     10  select 5, 're' from dual
     11  union
     12  select 6, 'tt' from dual
     13  union
     14  select 8, 'kl' from dual)
     15  select id,name
     16    from t1
     17   where id in (6,2,12,5,1)
     18*  order by decode( id, 6, 1, 2, 2, 12, 3, 5, 4, 1, 5 )
    SQL> /
    
            ID NA
    ---------- --
             6 tt
             2 a2
             5 re
             1 aa
    

    Justin

  • WITH query Clause does not work in Oracle reports.

    Hi gurus,

    I use a query WITH clause and want to create a report by using the same query.

    But when I am trying to build a report, request gives error like "WITH clause table or view does not exist.

    But the same query works perfectly in line of sql.

    Does support the Oracle WITH clause query reports?

    Please suggest.


    Thank you
    Onkar

    I met a similar problem before and worked around it by moving the query to a pipeline function in the database as described in the unexpected CLAUSE causes ORA-00942 in Report Builder

    I hope this helps.

  • Connect By hierarchical query clause-

    Hello

    I wrote a query using the Connect By clause to generate the table data structure tree with appropriate levels.

    But given could not correct as there may be data that did the trick. As Table1 is parent from table 2 and table 2 is parent from table 3 and table 3 is again Parent from table 1. If these incorrect data then I get error Oracle "ORA-01436: CONNECT loop in the user data" which is correct.

    What I need is, whenever this error message is triggered I give my own error instead of this Oracle error message in the SQL statement. Please note that I do not use any PLSQL block, I have just one SQL statement. Appreciate any help on this topic. Thank you.

    Hello

    Outside of PL/SQL, I don't know anyway to substitute your own error messages for those that oracle provides.

    In Oracle 10 (and more), you can write a query using the CONNECT_BY_ISCYCLE pseudo-column. Using CONNECTION BY NOCYCLE, the query will never actually throw the error ORA-01436, but you can get it to display your message in the case there, you not used CONNECT BY NOCYCLE.

    Here's how:
    Equip your actual query, CONNECT_BY_ISCYCLE, the WITH clause.
    Get this subquery (CONNECT_BY_ISCYCLE) MAX. We'll call this max_cbi.
    Do a UNION ALL of two pins:
    (1) selects everything (except, pehaps, CONNECT_BY_ISCYCLE), subquery, WHERE max_cbi = 0
    (2) allows you to select your 'error message' double, WHERE max_cbi = 1.

    Published by: Frank Kulash, November 26, 2008 14:09

  • RETURN TO THE UPDATE QUERY CLAUSE

    I have a request written in Postgres.   This will pick up the records in the table job_information with the State, as provided by the application (ex: "READY_TO_RUN") and with limit of records like the one provided by the application (ex: 100), then updates the job_information with app get (ex: "ACHIEVEMENTS") and returns that defined (means, returns the data table job_information total for these got put to date with the given State) records for the use of the application.

    Can someone give me advice on the translation in Oracle?   Thank you!!

    Query in Postgres

    UPDATE job_information AS J1
    SET status=?
    FROM
      (SELECT job_name,
        job_group,
        created_date
      FROM job_information
      WHERE status           =?
      AND CURRENT_TIMESTAMP >= scheduled_execution_time
      ORDER BY scheduled_execution_time limit ?
      ) AS J2
    WHERE J1.job_name   = J2.job_name
    AND J1.job_group    = J2.job_group
    AND J1.created_date = J2.created_date RETURNING *;
    

    Example of a query (in postgres):

    UPDATE job_information AS J1
    SET status= 'ACQUIRED'
    FROM
      (SELECT job_name,
        job_group,
        created_date
      FROM job_information
      WHERE status           = 'READY_TO_RUN'
      AND CURRENT_TIMESTAMP >= scheduled_execution_time
      ORDER BY scheduled_execution_time limit 100
      ) AS J2
    WHERE J1.job_name   = J2.job_name
    AND J1.job_group    = J2.job_group
    AND J1.created_date = J2.created_date RETURNING *;
    

    Oracle SQL - query, I wrote it is not working

    UPDATE JOB_INFORMATION SET STATUS=
    (
    WITH J2 as (
                            select job_name, job_group, created_date from (SELECT job_name, job_group, created_date FROM job_information WHERE status= :b and current_timestamp >= scheduled_execution_time order by scheduled_execution_time ) where rownum<= :c
                )
    SELECT distinct :a FROM JOB_INFORMATION J1, J2 WHERE J1.job_name = J2.job_name AND J1.job_group = J2.job_group AND J1.created_date = J2.created_date
    )
    RETURNING * FROM JOB_INFORMATION BULK COLLECT INTO SOMETHING ;
    
    1. create or replace package test_pack
    2. as
    3. type r_tab is (record
    4. test.job_name%type job_name,
    5. (status test.status%type);
    6. type t_tab is table of the r_tab;
    7. function test_func (v_status_o VARCHAR, v_status_i VARCHAR) - USE VARCHAR2
    8. T_tab RETURN PIPELINED;
    9. end;
    10. /
    11. create or replace the BODY of PACKAGE as test_pack
    12. function test_func (v_status_o VARCHAR2, v_status_i VARCHAR2) return t_tab pipelined as
    13. PRAGMA AUTONOMOUS_TRANSACTION;
    14. v_tab t_tab;
    15. Start
    16. Update test
    17. set status = v_status_o :-
    18. where Job_name in (select job_name TEST where status = :v_status_i).
    19. job_name, return STATUS
    20. bulk collect into v_tab;
    21. commit;
    22. because me in 1... loop v_tab. Count
    23. pipe row (v_tab (i));
    24. end loop;
    25. end;
    26. end;
    27. /

    REMOVE the colon before parameters and use the same types of data

  • How to display the output of query clause?

    Hello. I use Forms Developer 10g. I have a datablock that uses a from_clause_query. In my from_clause_query, I used a WITH AS SELECT.
    I try to view the output of this query in my forms but the first column, V_CUTOFF_TO not displayed, probably because it is not a database element. It was a result of my initial query WITH AS SELECT month. How can I view this with the release of my from_clause_query. Thanks in advance for the help. Moreover, I am trying to post the contents of my from_clause_query here, but it says sorry, this content is not allowed. I don't know why?

    I was able to solve the problem by creating a stored procedure. I insert the records in a table in the procedure, and then I query the table. Thanks for your help.

  • Query based ViewObject does pull not all attributes, when the query has 'WITH' clause

    Hello

    12.1.2 and 12.1.3 JDeveloper

    When we try to create a custom query based ViewObject, and the query clause of "with."

    So not all the columns selected in the query are appearing as attributes of the View object in the wizard.

    This is the query. And it performs very well in Toad.

    WITH dept_count AS)

    SELECT department_id, COUNT (*) AS dept_count

    Employees

    GROUP BY department_id)

    SELECT e.first_name AS employee_name,

    DC1.dept_count AS emp_dept_count,

    m.first_name AS manager_name,

    DC2.dept_count AS mgr_dept_count

    E employees,

    dept_count dc1,

    m employees,

    dept_count dc2

    WHERE e.department_id = dc1.department_id

    AND e.manager_id = m.employee_id

    AND m.department_id = dc2.department_id;

    Only the EmployeeName attribute is extracted from the query. It does not show the rest of the attributes in the VO Wizard.

    VO.png

    (I also tried to create a VO from the EntityObject class and make it editable as false, even in this case all attributes are not displayed.)

    I was wondering if something changed in 12 c?

    It works in 11.1.1.7

    (A friend of mine just asked me this).

    Thanks for any help.

    Sameer

    Jdev dislikes the syntax

    You can rewrite as

    SELECT e.first_name AS employee_name,

    DC1.dept_count AS emp_dept_count,

    m.first_name AS manager_name,

    DC2.dept_count AS mgr_dept_count

    E employees,

    (

    SELECT department_id, COUNT (*) AS dept_count

    Employees

    GROUP BY department_id) dc1,.

    m employees,

    (

    SELECT department_id, COUNT (*) AS dept_count

    Employees

    GROUP BY department_id) dc2

    WHERE e.department_id = dc1.department_id

    AND e.manager_id = m.employee_id

    AND m.department_id = dc2.department_id

    who must work and give you the same result.

    Timo

  • To loop through the table and use the values returned in another query

    Hello

    I tried to do something very simple, but still can not.

    I am trying to iterate on a table and use each line of a column in a where clause to display a query clause.

    For example:

    I want to retrieve all users of dba_users pass it to a clause where clause in a query to show for example account_status and profile of each user. But I want to do it in a way if I can turn the result in an html table.

    I tried too much really, so I'll post something that does not work, but which I think will show the problem I have,

    BEGIN
     FOR i IN (SELECT username from dba_users order by 1)
     LOOP
     EXECUTE IMMEDIATE 'select account_status from dba_users where username like ''||i.username||''';
     END LOOP;
     END;
     /
    

    Example of what I want to achieve:

    Suppose that there are two users, SYS, and SCOTT:

    USERNAME                       PROFILE                        ACCOUNT_STATUS
    ------------------------------ ------------------------------ --------------------------------
    SYS                            DEFAULT                        OPEN
    
    
    USERNAME                       PROFILE                        ACCOUNT_STATUS
    ------------------------------ ------------------------------ --------------------------------
    SCOTT                            DEFAULT                        OPEN
    

    Thanks in advance for your time,

    OD

    Hi Bill,

    Bill Citad kirjoitti:

    What a join or a sub query going to help me? honestly

    -- join
    select
      s.sql_id,
      h.loads_total
    from dba_hist_sqlstat h join v$sql s on (
      h.sql_id = s.sql_id
    )
    where rownum < 3
    ;
    
    -- subquery
    select
      sql_id,
      loads_total
    from dba_hist_sqlstat
    where sql_id in (
      select sql_id from v$sql where rownum < 3
    )
    ;
    
    -- correlated subquery
    select
      sql_id,
      loads_total
    from dba_hist_sqlstat
    where exists (
      select null from v$sql where sql_id = dba_hist_sqlstat.sql_id
    )
    and rownum < 3
    ;
    
    -- lateral inline view (12c)
    select
      s.sql_id,
      h.loads_total
    from dba_hist_sqlstat, lateral(
      select sql_id from v$sql where sql_id = h.sql_id
    ) s
    where rownum < 3
    ;
    

Maybe you are looking for

  • Connections to remember

    Until the recent update of FF I've never had a problem, but now I have to reconnect every time that I have leave some websites and then return. It drives me nuts, especially if I have two sites opened in tabs, and when I go back to the other, I have

  • Cloud TV - is - anyone tried the Plex app?

    I just discovered a new application of Plex on cloud TV. It's only for the plex subscribers pass which I am not. Anyone tried the Plex app? I hope those who work on the app made freely available soon.

  • Satellite A210 - 16G: position of changing cooling fans

    I bought the laptop Toshiba Satellite A210 - 16G.There is very little success.I didn't realize all the fans and heating when buying and now I have a lot of problems with it. It is fan is under the laptop and the fan distributes air through the left s

  • Create installers and executables LabVIEW

    Hi all I am trying to create an executable & installer for an application as described in http://zone.ni.com/devzone/cda/tut/p/id/5406. I have questions at once. I would like some advice. 1 EXE: I have attached a file called here zip 'exe screenshots

  • where is the tool button when I open the computer file

    I am trying to access my files from Ipod through the file 'computer '. Someone told me to click on the tool button in the menu bar, but it is not a. Where is he?