Preparing query through Inline View

Pls. help to prepare a query by i may extract the following data through inline view (i.e; other than using UNION):
1. SALESMAN who are working in deptno # 30
2. MANAGER who are working in deptno # 20
In department # 30 both SALESMAN and MANAGER are working likewise in department # 20 both SALESMAN and MANAGER are working.
I want to fetch only MANAGER from department # 20 and only SALESMAN from department 30.
I can fetch the above sought data through "UNION" but i know whether the above data can be fetched other than "UNION" like using INLINE VIEW.
INSERT INTO EMP
VALUES
(7369,'SMITH','CLERK',7902,'WEDNESDAY, DECEMBER 17, 1980',800,NULL,20)
INSERT INTO EMP
VALUES
(7499,'ALLEN','SALESMAN',7698,'FRIDAY, FEBRUARY 20, 1981',1600,300,30)
INSERT INTO EMP
VALUES
(7521,'WARD','SALESMAN',7698,'SUNDAY, FEBRUARY 22, 1981',1250,500,30)
INSERT INTO EMP
VALUES
(7566,'JONES','MANAGER',7839,'THURSDAY, APRIL 02, 1981',2975,NULL,20)
INSERT INTO EMP
VALUES
(7654,'MARTIN','SALESMAN',7698,'MONDAY, SEPTEMBER 28, 1981',1250,1400,30)
INSERT INTO EMP
VALUES
(7698,'BLAKE','MANAGER',7839,'FRIDAY, MAY 01, 1981',2850,NULL,30)
INSERT INTO EMP
VALUES
(7782,'CLARK','MANAGER',7839,'TUESDAY, JUNE 09, 1981',2450,NULL,10)
INSERT INTO EMP
VALUES
(7788,'SCOTT','ANALYST',7566,'SUNDAY, APRIL 19, 1987',3000,NULL,20)
INSERT INTO EMP
VALUES
(7839,'KING','PRESIDENT',NULL,'TUESDAY, NOVEMBER 17, 1981',5000,NULL,10)
INSERT INTO EMP
VALUES
(7844,'TURNER','SALESMAN',7698,'TUESDAY, SEPTEMBER 08, 1981',1500,0,30)
INSERT INTO EMP
VALUES
(7876,'ADAMS','CLERK',7788,'SATURDAY, MAY 23, 1987',1100,NULL,20)
INSERT INTO EMP
VALUES
(7900,'JAMES','CLERK',7698,'THURSDAY, DECEMBER 03, 1981',950,NULL,30)
INSERT INTO EMP
VALUES
(7902,'FORD','ANALYST',7566,'THURSDAY, DECEMBER 03, 1981',3000,NULL,20)
INSERT INTO EMP
VALUES
(7934,'MILLER','CLERK',7782,'SATURDAY, JANUARY 23, 1982',1300,NULL,10)
INSERT INTO EMP
VALUES
(100,'SALAM','SALESMAN',7698,'FRIDAY, FEBRUARY 20, 1981',1600,300,20)
INSERT INTO EMP
VALUES
(101,'KARIN','SALESMAN',7698,'SATURDAY, FEBRUARY 21, 1981',1250,500,20)
INSERT INTO EMP
VALUES
(102,'RAFIQ','SALESMAN',7698,'SATURDAY, FEBRUARY 20, 1988',1250,1400,20)
INSERT INTO EMP
VALUES
(103,'JABBAR','SALESMAN',7698,'WEDNESDAY, FEBRUARY 20, 1980',1500,0,20)
INSERT INTO EMP
VALUES
(500,'RAHIM','MANAGER',7839,'THURSDAY, DECEMBER 16, 1971',2975,NULL,20)
/thanks.
Sharif
Edited by: user13094274 on May 8, 2010 6:49 AM

CREATE TABLE emp
    (empno                          NUMBER(4,0) NOT NULL,
    ename                          VARCHAR2(10),
    job                            VARCHAR2(9),
    mgr                            NUMBER(4,0),
    hiredate                       DATE,
    sal                            NUMBER(7,2),
    comm                           NUMBER(7,2),
    deptno                         NUMBER(2,0))

Similar Messages

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • Tuning query with inline views

    Hi!
    I have a performance problem with the following query. I try to combine v1 and v2 into one inline view but because of the recursive design of the tables workflow and workflow_node it didn't work.
    Does anybody has an idea for tuning this query?
    SELECT distinct v1.u_protocol_id
       FROM ( SELECT workflow_node.workflow_id,u_protocol.u_protocol_id
                   FROM workflow_node,workflow,U_protocol
                   WHERE workflow.workflow_id=workflow_node.workflow_id
                     AND u_protocol.u_protocol_id = workflow_node.parameter_2
                  AND workflow_node.workflow_node_type_id=17
                  AND workflow.workflow_node_type_id=42
             ) v1,
             ( SELECT workflow_node.workflow_id,test_template.test_template_id
               FROM workflow_node,test_template
               WHERE test_template.test_template_id = workflow_node.template
                 AND workflow_node.order_number = 1
                 AND workflow_node.workflow_node_type_id=42
             ) v2,
             ( SELECT aliquot.aliquot_id,test_template.test_template_id
               FROM aliquot,test,test_template
               WHERE aliquot.aliquot_id = test.aliquot_id
                 AND test.test_template_id = test_template.test_template_id
             ) v3
       WHERE v1.workflow_id = v2.workflow_id
         AND v2.test_template_id= v3.test_template_id

    I have found a script (utlxplan.sql) for creating the plan_table so here it is
    SQL> @c:\utlxplan.sql;
    Table created.
    SQL> EXPLAIN PLAN FOR SELECT distinct v1.u_protocol_id
      2     FROM ( SELECT workflow_node.workflow_id,u_protocol.u_protocol_id
      3         FROM lims_sys.workflow_node,lims_sys.workflow,lims_sys.U_protocol
      4         WHERE workflow.workflow_id=workflow_node.workflow_id
      5           AND u_protocol.u_protocol_id = workflow_node.parameter_2
      6        AND workflow_node.workflow_node_type_id=17
      7        AND workflow.workflow_node_type_id=42
      8       ) v1,
      9       ( SELECT workflow_node.workflow_id,test_template.test_template_id
    10         FROM lims_sys.aliquot,lims_sys.test,lims_sys.workflow_node,lims_sys.test_template
    11         WHERE aliquot.aliquot_id = test.aliquot_id
    12           AND test.test_template_id = test_template.test_template_id
    13     AND test_template.test_template_id = workflow_node.template
    14       ) v2
    15     WHERE v1.workflow_id = v2.workflow_id
    16  /
    Explained.
    SQL> SELECT * FROM TABLE(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation                           |  Name                           |
    Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT                    |                                 |
    PLAN_TABLE_OUTPUT
          |       |       |
    |   1 |  SORT UNIQUE                        |                                 |
          |       |       |
    |   2 |   FILTER                            |                                 |
          |       |       |
    |   3 |    NESTED LOOPS                     |                                 |
          |       |       |
    PLAN_TABLE_OUTPUT
    |   4 |     NESTED LOOPS                    |                                 |
          |       |       |
    |   5 |      NESTED LOOPS                   |                                 |
          |       |       |
    |   6 |       NESTED LOOPS                  |                                 |
          |       |       |
    |   7 |        NESTED LOOPS                 |                                 |
          |       |       |
    PLAN_TABLE_OUTPUT
    |   8 |         NESTED LOOPS                |                                 |
          |       |       |
    |   9 |          TABLE ACCESS BY INDEX ROWID| WORKFLOW                        |
          |       |       |
    |* 10 |           INDEX RANGE SCAN          | FK_WORKFLOW_WORKFLOW_NODE_TYPE  |
          |       |       |
    |  11 |          TABLE ACCESS BY INDEX ROWID| WORKFLOW_NODE                   |
    PLAN_TABLE_OUTPUT
          |       |       |
    |  12 |           AND-EQUAL                 |                                 |
          |       |       |
    |* 13 |            INDEX RANGE SCAN         | FK_WORKFLOW_NODE_WORKFLOW       |
          |       |       |
    |* 14 |            INDEX RANGE SCAN         | FK_WORKFLOW_NODE_NODE_TYPE      |
          |       |       |
    PLAN_TABLE_OUTPUT
    |  15 |         TABLE ACCESS BY INDEX ROWID | U_PROTOCOL                      |
          |       |       |
    |* 16 |          INDEX UNIQUE SCAN          | PK_U_PROTOCOL                   |
          |       |       |
    |  17 |        TABLE ACCESS BY INDEX ROWID  | WORKFLOW_NODE                   |
          |       |       |
    |* 18 |         INDEX RANGE SCAN            | FK_WORKFLOW_NODE_WORKFLOW       |
          |       |       |
    PLAN_TABLE_OUTPUT
    |  19 |       TABLE ACCESS BY INDEX ROWID   | TEST_TEMPLATE                   |
          |       |       |
    |* 20 |        INDEX UNIQUE SCAN            | PK_TEST_TEMPLATE                |
          |       |       |
    |  21 |      TABLE ACCESS BY INDEX ROWID    | TEST                            |
          |       |       |
    |* 22 |       INDEX RANGE SCAN              | FK_TEST_TEST_TEMPLATE           |
    PLAN_TABLE_OUTPUT
          |       |       |
    |  23 |     TABLE ACCESS BY INDEX ROWID     | ALIQUOT                         |
          |       |       |
    |* 24 |      INDEX UNIQUE SCAN              | PK_ALIQUOT                      |
          |       |       |
    |  25 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    PLAN_TABLE_OUTPUT
    |  26 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    |  27 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    |  28 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    |  29 |    INDEX UNIQUE SCAN                | PK_OPERATOR_GROUP               |
          |       |       |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
      10 - access("SYS_ALIAS_5"."WORKFLOW_NODE_TYPE_ID"=42)
      13 - access("SYS_ALIAS_5"."WORKFLOW_ID"="WORKFLOW_NODE"."WORKFLOW_ID")
      14 - access("WORKFLOW_NODE"."WORKFLOW_NODE_TYPE_ID"=17)
    PLAN_TABLE_OUTPUT
      16 - access("SYS_ALIAS_4"."U_PROTOCOL_ID"=TO_NUMBER("WORKFLOW_NODE"."PARAMETER
    _2"))
      18 - access("WORKFLOW_NODE"."WORKFLOW_ID"="WORKFLOW_NODE"."WORKFLOW_ID")
      20 - access("SYS_ALIAS_1"."TEST_TEMPLATE_ID"="WORKFLOW_NODE"."TEMPLATE")
      22 - access("SYS_ALIAS_2"."TEST_TEMPLATE_ID"="SYS_ALIAS_1"."TEST_TEMPLATE_ID")
      24 - access("SYS_ALIAS_3"."ALIQUOT_ID"="SYS_ALIAS_2"."ALIQUOT_ID")
    Note: rule based optimization

  • Query works everywhere but Flex: inline views not supported perhaps?

    EDIT2: Actually not. It turns out to be a bug in the way Adobe is treating any integer PK column, no matter how it is defined, INT, or INTEGER, as an alias for the rowid in SQlite.  This is incorrect. rowid does not always equal the PK value.  This causes joins to return the wrong values.
    EDIT: turns out to be the use of the absolute value function in the query.
    See http://forums.adobe.com/thread/516392
    My bread-and-butter query, the one that is the core of my application, uses a UNION query with inline views when doing proximity word-searches. It works beautifully in SQLite returning a resultset  in about one second from an over 300MB database, against several tables equijoined, the two biggest tables having close to 4 million rows and 300,000 rows, respectively.
    It runs fine in Visual Studio using the .NET provider for SQLite, and also in SQLite Manager 0.5.6 by Mrinal Kant and in other front-ends to SQLite. But the verbatim query returns no rows in Flex and zero rows in the SQLite Admin GUI front-end, which is built on the Flex SQL libraries.
    My first thought is that inline views might not be supported in Flex? 
    Does Flex do what in the Microsoft world is called a "pass-through" query, sending the sql intact through to the back end, or does Flex take the query statement apart and apply the WHERE clause conditions client-side, as Microsoft Access does to support so-called "heterogeneous" joins, i.e. queries that might join tables from, say, SQL Server and Oracle in the same query?

    EDIT2: Actually not. It turns out to be a bug in the way Adobe is treating any integer PK column, no matter how it is defined, INT, or INTEGER, as an alias for the rowid in SQlite.  This is incorrect. rowid does not always equal the PK value.  This causes joins to return the wrong values.
    EDIT: turns out to be the use of the absolute value function in the query.
    See http://forums.adobe.com/thread/516392
    My bread-and-butter query, the one that is the core of my application, uses a UNION query with inline views when doing proximity word-searches. It works beautifully in SQLite returning a resultset  in about one second from an over 300MB database, against several tables equijoined, the two biggest tables having close to 4 million rows and 300,000 rows, respectively.
    It runs fine in Visual Studio using the .NET provider for SQLite, and also in SQLite Manager 0.5.6 by Mrinal Kant and in other front-ends to SQLite. But the verbatim query returns no rows in Flex and zero rows in the SQLite Admin GUI front-end, which is built on the Flex SQL libraries.
    My first thought is that inline views might not be supported in Flex? 
    Does Flex do what in the Microsoft world is called a "pass-through" query, sending the sql intact through to the back end, or does Flex take the query statement apart and apply the WHERE clause conditions client-side, as Microsoft Access does to support so-called "heterogeneous" joins, i.e. queries that might join tables from, say, SQL Server and Oracle in the same query?

  • Inline views / view merge slowing the query

    I have a tool generated query. This query uses inline views. The individual view return data under a second but final query is taking 10min +. any suggestion.
    I tried /*+ NO_MERGE(D1,D2,D3,D4)*/ but to no help.
    TIA.
    SELECT /*+ NO_MERGE(D1,D2,D3,D4)*/DISTINCT d4.c5 AS c1, d2.c14 AS c2,
    d3.c8 AS c3, d2.c8 AS c4,
    d2.c9 AS c5, d2.c10 AS c6,
    d2.c11 AS c7, d2.c12 AS c8,
    d2.c13 AS c9
    FROM (vv_d1) d1,
    (vv_d2) d2,
    (vv_d3) d3,
    (vv_d4) d4
    WHERE ( NVL (d1.c1, 'q') =
    NVL (d2.c14, 'q')
    AND NVL (d1.c1, 'z') =
    NVL (d2.c14, 'z')
    AND NVL (d1.c3, 'q') =
    NVL (d2.c12, 'q')
    AND NVL (d1.c3, 'z') =
    NVL (d2.c12, 'z')
    AND NVL (d1.c6, 'q') =
    NVL (d2.c9, 'q')
    AND NVL (d1.c6, 'z') =
    NVL (d2.c9, 'z')
    AND NVL (d1.c4, 'q') =
    NVL (d2.c10, 'q')
    AND NVL (d1.c4, 'z') =
    NVL (d2.c10, 'z')
    AND NVL (d1.c5, 8) =
    NVL (d2.c13, 8)
    AND NVL (d1.c5, 9) =
    NVL (d2.c13, 9)
    AND NVL (d1.c1, 'q') =
    NVL (d4.c6, 'q')
    AND NVL (d1.c1, 'z') =
    NVL (d4.c6, 'z')
    AND NVL (d1.c1, 'q') =
    NVL (d3.c11, 'q')
    AND NVL (d1.c1, 'z') =
    NVL (d3.c11, 'z')
    AND NVL (d1.c2, 88.0) =
    NVL (d3.c9, 88.0)
    AND NVL (d1.c2, 99.0) =
    NVL (d3.c9, 99.0)
    AND NVL (d1.c3, 'q') =
    NVL (d3.c10, 'q')
    AND NVL (d1.c3, 'z') =
    NVL (d3.c10, 'z')
    AND NVL (d1.c7, 'q') =
    NVL (d2.c11, 'q')
    AND NVL (d1.c7, 'z') =
    NVL (d2.c11, 'z')
    )

    And the Oracle version number, to three decimal places is?
    Post EXPLAIN PLAN output created using dbms_xplan
    http://www.psoug.org/reference/explain_plan.html

  • Difference between INLINE view and WITH clause

    Can anyone plz explain me about the performance difference between the below queries?
    Query using INLINE view:
    SELECT e.ename AS employee_name,
    dc.dept_count AS emp_dept_count
    FROM emp e,
    (SELECT deptno, COUNT(*) AS dept_count
    FROM emp
    GROUP BY deptno) dc
    WHERE e.deptno = dc.deptno;
    Query using WITH clause:
    WITH dept_count AS (
    SELECT deptno, COUNT(*) AS dept_count
    FROM emp
    GROUP BY deptno)
    SELECT e.ename AS employee_name,
    dc.dept_count AS emp_dept_count
    FROM emp e,
    dept_count dc
    WHERE e.deptno = dc.deptno;

    Here's another one:
    http://www.oracle-base.com/articles/misc/WithClause.php
    And, here on this forum you will see that the WITH-clause is heavily used by all of us in order to generate some sample data (when OP's don't care to post CREATE TABLE + INSERT INTO statements).
    The WITH clause enables you as well to 'pretend' you have a table and demonstrate a solution very quickly, without doing actual DDL .
    As for the performance difference:
    We would need to know your database version and many other things.
    See:
    HOW TO: Post a SQL statement tuning request - template posting
    for step by step instructions you can (and should) explore yourself.

  • Passing a value to Inline View  WHERE clause through JDev...

    Hi ,
    I need to pass a value to inline view which is mentioned in below VIEW query.
    That view is created inside a view using jDev. Note that there are two WHERE clauses one in the Main query and the other in the Inline view.
    How to set the value for the innerView.
    //copied the code from Java
    view.volAlertsHistroyView.setWhereClauseParam(1, new Integer(clientId));
    Gives an error Missing IN or OUT parameter at index:: 1
    SELECT Alerts.SEND_TIME,
         Alerts.STATUS,
         Alerts.TEXT ,
         Groups.NAME,
              VolRoles.ROLE_NAME,
                   VolRoles.ID as vid,
                   Groups.ID as gid
         FROM ALERTS Alerts, ALERTS_GROUPS AlertsGroups, GROUPS Groups, VOL_ROLES VolRoles,
    --Inline view starts
    (SELECT GRP_ID, VRL_ID FROM vol_groups WHERE cli_id = :1) user_group_role
    --Inline view ends
    --Actual WHERE clause starts
         WHERE ((Alerts.ID = AlertsGroups.ALT_ID)AND (AlertsGroups.GRP_ID = Groups.ID))AND (AlertsGroups.VRL_ID = VolRoles.ID)
         AND AlertsGroups.VRL_ID = user_group_role.VRL_ID AND AlertsGroups.GRP_ID = user_group_role.GRP_ID
    Please get back to me .
    Regards
    Mohan
    [email protected]

    What happens when you change your Java code to:
    view.volAlertsHistroyView.setWhereClauseParam(0, new Integer(clientId));
    The ":1" does not directly relate to the where clause param index you use in Java. In your query you could also use a ":2" for example. In BC4J you still use "0" for the first param.
    Sascha

  • Can You Explain This SQL Query - Inline View Included

    The query is taken from "Oracle Database 10g: SQL Fundamentals II" page 3-7 (chapter 3)
    I do not fully understand the following query:
    SELECT a.last_name, a.salary, a.department_id, b.salavg
    FROM   employees a, (SELECT   department_id,
    AVG(salary) salavg
    FROM     employees
    GROUP BY department_id) b
    WHERE  a.department_id = b.department_id
    AND    a.salary > b.salavg;
    The inline view can return several records. Can you please tell me in step by step how does this work. I understand the concept of join tables and aliases, etc. I just need to know the mechanism of this code.
    Thanks

    user11164565 wrote:
    The query is taken from "Oracle Database 10g: SQL Fundamentals II" page 3-7 (chapter 3)
    I do not fully understand the following query:
    SELECT a.last_name, a.salary, a.department_id, b.salavg
    FROM   employees a, (SELECT   department_id,
    AVG(salary) salavg
    FROM     employees
    GROUP BY department_id) b
    WHERE  a.department_id = b.department_id
    AND    a.salary > b.salavg;
    The inline view can return several records. Can you please tell me in step by step how does this work. I understand the concept of join tables and aliases, etc. I just need to know the mechanism of this code.
    The query is returning the last name, salary , department and average salary of all the departments where salary is greater than the average salary.
    HTH
    Aman....

  • Improve performance of  an inline view query

    All,
    I have a unique situation where I have to limit the number of rows based on group. so I created an Inline view and applied a limit on it.
    ex:
    SELECT col_A, col_B FROM ( SELECT col_a, count(*) FROM tab_a WHERE col_a = 'XXX' GROUP BY col_a) ROWNUM <-10.
    but this design was rejected, because it seems to have a great impact on performance due to inline view.
    Also I cant set a rowlimit directly on the query because GROUP BY clause is used in the select.
    When the rownum is directly applied in the WHERE, first it limits the rows and then it makes a GROUP, so when user asks to retrieve 10 records, it may show less than 10 rows because of the grouping.
    please help to find a alternative solution which helps to get the expected result set and same time without loosing performance.

    Hi,
    The sql you gave us is not valid. There is no "col_b" in your inline view, there is no "where" before "rownum<10", and the inline view returns only one row.
    Try to produce a reproducible scenario with scott.emp and scott.dept generated by $ORACLE_HOME/rdbms/admin/utlsampl.sql
    Regards
    Laurent

  • Improve Performance on Inline view Query

    All,
    I have a unique situation where I have to limit the number of rows based on group. so I created an Inline view and applied a limit on it.
    ex:
    SELECT col_A, col_B FROM ( SELECT col_a, count(*) FROM tab_a WHERE col_a = 'XXX' GROUP BY col_a) ROWNUM <-10.
    but this design was rejected, because it seems to have a great impact on performance due to inline view.
    Also I cant set a rowlimit directly on the query because GROUP BY clause is used in the select.
    When the rownum is directly applied in the WHERE, first it limits the rows and then it makes a GROUP, so when user asks to retrieve 10 records, it may show less than 10 rows because of the grouping.
    please help to find a alternative solution which helps to get the expected result set and same time without loosing performance

    but this design was rejected, because it seems to have a great impact on performance due to inline view.What proof was offered that this query performed badly. There is nothing inherently non-performant about in-line views. I would demand to see some evidence that this query uses an unreasonable amount of system resource.
    However, you could try this:
    SELECT t.col1, avg(t.col2)
    FROM   t1 t
    WHERE  t.col1 IN ( SELECT DISTINCT x.col1
                       FROM   t1 x
                       WHERE  col3 = 'XXX'
                       AND    rownum <=10 )
    GROUP  BY t.col1
    /I assume your example is not derived from your real code (otherwise the WHERE clause would restrict the inline query to one returned row - problem solved!)
    Cheers, APC

  • Junk characters displayed when viewing BEx query through WAD

    Hello,
    I am trying to display the results of a web report containing a BEx query through the "Execute in the Browser" option in WAD. But, junk Chinese characters keep showing up in the display. Also, if I try the same with one of the older web reports, they display fine. But, the moment I make a copy of these and execute without any modifications, the junk characters show up again.
    I tried executing through RSRT and there my report works perfectly. So, what could be going wrong or am I missing something?
    Thanks in advance!
    Menaz

    Thanks Emma.
    We figured it was related to the Unicode charset while I was going through the source code. I don't think there is any permanent fix yet. But, I followed the posting below and am trying to temporarily fix the error:
    Web Application Designer Appearing in Unicode (UTF-8)
    Thank you!

  • Issue with Inline View Criteria

    Hi,
    I have a VO created on two tables that are joined by a 1:1 association(say Opportunity and Revenue). The query is specified in Expert mode because I need some aggregations performed using analytic functions. Data security predicates are applied on top of this query using a dummy View Criteria. My requirement now is that I need to filter these results using another VC. The issue is that both the tables have attributes with the same name(say Cust ID) and I need to filter based on this using an inline View Criteria. I have done the same declaratively. However, I get an error on hitting the page saying the columns have been ambiguously defined.
    On digging through the log, I discovered the test Query fails to prefix the alias before the attribute. So what I get is something similar to this
    select (o.id, r.amt, sum(), count(), avg(), o.custId) from opty o, revn r where (o.id in DATA SECURITY PREDICATE) and (custId = :bindCustId)
    Is there a way to ensure that the custId can be changed to o.custId???
    Note - The View Criteria was created on an attribute from opty table that was exposed i.e in this case, o.custId. Although the query builder shows it correctly while creating the VC declaratively, the issue persists as seen from the logs.
    Thanks,
    Manoj

    Hi experts...
    Any pointers to this issue???
    Please help!
    Regards,
    Debolina

  • Query SharePoint List View

    As per http://msdn.microsoft.com/en-us/library/ms434064.aspx if we use
    list.GetItems(query, view.ID.ToString("B").ToUpper());
    properties of the view that is specified by the viewName parameter override the properties that are specified in the query object that is passed through the query parameter. For example, if the query
    object includes a tag that specifies only items containing a particular column value, while the view specifies to return all items, this method retrieves all of the items
    So is there any way to query a sharepoint list view (not All Items) using CAML query?
    I this retrieving view in a data table and query it later, which is an option but might give a performance degradation.
    Regards, Aj (http://www.aj-sharepoint.blogspot.com/) MCTS

    Hello,
    Did you try with SPView.Query method? If not then this can be query to specific view.
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spview.query.aspx
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How can i see the values of a prepared query

    Somebody knows about a tool that show me the values of a prepared query.
    I tried with the view V$SQL and with the TKPROF, but both show me the same query text and i need to know the parameter's values. Example of a prepared query - I don't know if it is the correct name of that kind of query.
    UPDATE "CL0E01" SET "BLOQUEO"=:1
    WHERE
    "CLAVE"=:2 AND "NUM_REGS"=:3 AND "ULT_CLV"=:4 AND "BLOQUEO"=:5
    Is it a tool that show me the value??
    Thanks for the help.
    Roberto Moreno

    I tried with the view V$SQL_BIND_CAPTURE but i get this error. "ORA-00932: inconsistent datatypes: expected CHAR got -". I executed in the Application Express.
    What could be wrong??
    I put my STATISTICS_LEVEL to ALL but nothing happen. I recieved the same result.
    I executed the view V$STATISTICS_LEVEL, for the Bind Data Capture I have enabled the session and system status, the activation level is TYPICAL.
    Thanks for your help TongucY

  • Does an inline view execute before the rest of the select?

    Hi,
    The O'Reilly book Mastering Oracle Sql defines an inline view simply as a
    subquery in a select FROM clause. This conforms to the definitions in
    the Oracle 9i and 10g docs.
    But unlike the Oracle docs, the O'Reilly book says the inline view is,
    like a WITH clause, executed before the rest of the query. I can't see
    how this can be done unless the inline view makes no reference to
    other tables joined in the FROM clause.
    Is there a species of inline view in 9i/10g that IS restricted as above -
    no refs to other tables in the FROM clause - and what is it called?
    Thanks for any help.
    Ken Quirici

    As explained above, Oracle can choose to merge the query if feasible to do so. Look at the two queries and their plans below. The plan in second query changes to creating a temporary VIEW since in that case, Oracle is unable to perform the merge:
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO     DEPTNO DNAME          LOC
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10         10 ACCOUNTING     NEW YORK
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10         10 ACCOUNTING     NEW YORK
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10         10 ACCOUNTING     NEW YORK
    3 rows selected.
    Execution Plan
    Plan hash value: 3570059291
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                |     3 |   171 |     2   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                |     3 |   171 |     2   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT           |     1 |    20 |     1   (0)| 00:00:01 |
    |*  3 |    INDEX UNIQUE SCAN         | PK_DEPT        |     1 |       |     0   (0)| 00:00:01 |
    |   4 |   TABLE ACCESS BY INDEX ROWID| EMP            |     3 |   111 |     1   (0)| 00:00:01 |
    |*  5 |    INDEX RANGE SCAN          | IDX_EMP_DEPTNO |     3 |       |     0   (0)| 00:00:01 |
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10 and rownum > 0) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO     DEPTNO DNAME          LOC
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10         10 ACCOUNTING     NEW YORK
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10         10 ACCOUNTING     NEW YORK
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10         10 ACCOUNTING     NEW YORK
    3 rows selected.
    Execution Plan
    Plan hash value: 1670713873
    | Id  | Operation                       | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |                |     5 |   280 |     2   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                   |                |     5 |   280 |     2   (0)| 00:00:01 |
    |   2 |   VIEW                          |                |     1 |    19 |     1   (0)| 00:00:01 |
    |   3 |    COUNT                        |                |       |       |            |          |
    |*  4 |     FILTER                      |                |       |       |            |          |
    |   5 |      TABLE ACCESS BY INDEX ROWID| DEPT           |     1 |    20 |     1   (0)| 00:00:01 |
    |*  6 |       INDEX UNIQUE SCAN         | PK_DEPT        |     1 |       |     0   (0)| 00:00:01 |
    |   7 |   TABLE ACCESS BY INDEX ROWID   | EMP            |     5 |   185 |     1   (0)| 00:00:01 |
    |*  8 |    INDEX RANGE SCAN             | IDX_EMP_DEPTNO |     5 |       |     0   (0)| 00:00:01 |
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL>
    can it, in it's WHERE clause, reference other tables in the FROM clause?No. it cannot. but as said above, tha may not stop Oracle from merging the queries.
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10 and e.sal > 1000) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
                    (select * from scott.dept d where d.deptno = 10 and e.sal > 1000) dd
    ERROR at line 3:
    ORA-00904: "E"."SAL": invalid identifier
    SQL>

Maybe you are looking for

  • Safari crash report

    So I think a faulty extension was downloaded, no idea how because I don't download any extensions. It had something to do with internet explorer but I deleted it in hope that it would stop my safari from crashing and so I forgot the name of the exten

  • Installing Adobe CS2 Again On my Mac pro

    I insert the install disk and it comes up on the computer..When I hit the install Photoshop Button I get the following error message (An error occurred attempting to expand Adobe Photoshop CS2 MPKG.. a Folder was specified when a file was required. E

  • How to get "consolidator connections" in the Navigator

    Greetings, My problem is with oracle 8i lite as follows: I never got in the navigator the "consolidator connections" I only get on the left of the screen of the navigator -"databases" -"connections" So my question is: How can i get my navigator with

  • BB wont turn on, wont recognize battery. HELP

    Hi, hoping i can still salvage my curve. here's the problem: a few days ago i droped my BB curve 8320. (it was on carpet, indoors, no moisture). Naturally it turned off, and will not turn back on. the only reaction i get is: A) when the battery is re

  • Auto-login using cookies

    I have been prototyping and researching Weblogic authentication for several weeks now. With a form-based login servlet, how would one implement auto-login? Basically, the web site is supposed to set a persistent cookie which contains the users login