Order by clause with Named Query

hi
i have to give order by clause in Named Query
how we have to specify is can any body help
thanks
Harish

Assuming an Entity called Handset:
select h from Handset h order by h.description

Similar Messages

  • Order by clause in Sub query

    Hi,
    Can we use order by clause in Sub query?
    While using the order by clause, I am getting the "missing expression error" . If I remove order by clause query executing fine.
    Here is my query:
    select *
    from emp_mstr
    where emp_no in(select
    emp_no
    from emp_mstr
    order by branch_no);
    Thanks & Regards,
    Mahi

    May be you miss some required spaces also, other than wrong use of ORDER BY
    select *
    from emp_mstr
    where emp_no in
         ( select e2.emp_no
           from emp_mstr e2
    --       order by e2.branch_no
         );Why do you want to ORDER BY in the subquery, which you use with IN clause? That will not make any difference in the result..Means the result you get with ORDER BY will be same as without that.. And in this case, ORDER by is a unncessary overhead.. And Ordering is very costly..
    And why do you want to have the IN clause at all in your query? You are referring the same tables in the main query and sub query..
    The below will give the same result
    select *
    from emp_mstr
    where emp_no is not nullIf you want to use another table in the subquery, always use aliasess...
    select *
    from emp_mstr
    where emp_no in
         ( select e2.emp_no
           from emp_mstr2 e2
    --       order by e2.branch_no
         );

  • Decode in order by clause with desc

    I want to user order by clause with decode + desc order.
    somthing like
    ORDER BY DECODE ('SALE', e.sale, 'SALE DESC' ????)
    ????-> How to use desc order with decode
    Thanks in advance

    I thought smart people in this OTN community will understand that I am trying to order by the thisdate column that is timestamp datatype:). My apologize for not being that specific.
    The query I gave is a simple version of the stored procedure I am using. The point is I need to order by - depending on one of the parameters that is passed to the procedure. In simplest decode statements, its something like
    order by decode(p_in_var,'ABC','thisdate asc','DEF','thisdate desc',thisdate asc)
    Here p_in_var is varchar input parameter to the stored procedure.
    Please let me know if there is any more information needed.
    Thx!

  • Suppress "Order By" clause in Answers Query

    Hello,
    Is it possible to Suppress "Order By" clause in Answers Query.
    I'm using a database view as data source. In the view definition, "order by" clause is already specified. Is it possible to get the same order in the OBIEE report??
    I do not want to use Sort Order column in the repository.
    Thanks,
    Girish

    You add a rownumber to your DB view and use that to 'sort' your report.
    regards
    John
    http://obiee101.blogspot.com/

  • IS IT POSSIBLE TO  WRITE ORDER BY CLAUSE WITHIN INNER QUERY

    IS IT POSSIBLE TO WRITE ORDER BY CLAUSE WITHIN INNER QUERY

    So you still can't :) I still don't see it that strict:
    You know of course that this is possible:
    select ename, (select ename
                     from (select   empno, ename
                               from emp
                              where deptno = 10
                           order by 1) e2
                    where e.empno = e2.empno) a
      from emp eso we have an »ORDER BY CLAUSE WITHIN INNER QUERY« which is even correlated (though through the outer query).
    Whether this makes sense or not is not question imho :-) ... but you can

  • Order by clause with union

    Hi,
    I wanted to know if this is possible with order by clause and union. some how union messes up the ordering of the left part of the union statement.
    assume the data is as below in table tab1
    c1 c2
    4 1
    4 2
    5 1
    5 2
    7 1
    7 2
    8 3
    9 4
    the expected output must be for all c1 < 7 ordering must be on c1 and for all c1 > 7 ordering must be on c2.
    so the query i tried was
    select c1,c2 from tab1 where c1 <7 order by c1
    union
    select c1,c2 from tab1 where c1 >=7 order by c2
    it is giving the message 'Sql command not properly ended'.
    Suggestions are welcome

    SQL>
    SQL> With t As
      2  (
      3  Select 4 c1, 1 c2 From dual Union All
      4  Select 4 ,2       From dual Union All
      5  Select 5 ,1       From dual Union All
      6  Select 5 ,2       From dual Union All
      7  Select 7 ,1       From dual Union All
      8  Select 7 ,2       From dual Union All
      9  Select 8 ,3       From dual Union All
    10  Select 9 ,4       From dual
    11  ), t1 As (Select c1,c2 From t Where c1 <7 Order By c1)
    12  ,t2 As (select c1,c2 from t where c1 >=7 Order By c2)
    13  Select * From t1 Union All
    14  Select * From t2;
            C1         C2
             4          1
             4          2
             5          1
             5          2
             7          1
             7          2
             8          3
             9          4
    8 rows selected
    SQL> /*-- Union All
      2   select c1,c2 from t where c1 >=7
      3   Order By c1,c2;
      4  */
      5 
    with union clause order by must be placed in the end,,
    select c1 from dual union all
    select c2 from dual
    order by  c1

  • Order By Clause with Empty Field values !

    Hello,
    In Oracle , the order by clause does not return the expected query result, if any of the field value in the order by clause has an empty string.
    Oracle treats the empty string as null value and ORDER BY gives a result with the empty string field values listed at last.
    For example :
    test is a sample table containing "name" field.
    Query: "select name from test order by name"
    In SQL Server/Access
    Result (1)
    NAME
    (blank)
    (blank)
    User1
    User2
    User3
    In Oracle
    Result (2)
    NAME
    User1
    User2
    User3
    (blank)
    (blank)
    I know some of the Work arounds for this as listed below :
    1) To use NVL in Order By Clause.
    i.e., the modified query
    "select name from test order by nvl(name,0)"
    gives the result same as Result (1).
    2) To have single blank space in the field value if it is empty.
    I dont want to use either of these two options b'se it would lead to a mass change in my existing code.
    Is there any way i can do a
    collation order settings in the Oracle databases to get the results as in MS SQL/Access.
    Can Any help me out in Solving this?
    Thanks
    Devi Shankar
    null

    Bharath,
    I am moving this question to the SQL forum.
    Regards,
    Geoff

  • ORDER BY clause with expression

    Considering that all the column names and table name is valid, what happens internally when the following query is run?
    SQL> SELECT STU_ID, STU_NAME FROM STUDENT ORDER BY 2+3, STU_ID;
    What i found out was the rows get ordered in ascending order of STU_ID. It's quite clear that it is ignoring the expressing 2+3, so my doubts are:
    (a) Is it appending any pseudo-column to the table with 2+3 getting evaluated to 5?
    (b) If there exist a 5th column in the table student and we specify it in the select statement's select list (5 column names) then why its not considering it as 5 and sorting the data according that?
    (c) Is it true that, any expression we write is getting evaluated to NULL? Then is it that ORDER BY NULL evaluates to no ordering and the parser searches for next column-name or position (if specified) ?
    (d) if neither then, what's the reason of the ignorance?

    Hi,
    Welcome to the forum!
    987236 wrote:
    Considering that all the column names and table name is valid, what happens internally when the following query is run?
    SQL> SELECT STU_ID, STU_NAME FROM STUDENT ORDER BY 2+3, STU_ID;
    What i found out was the rows get ordered in ascending order of STU_ID. It's quite clear that it is ignoring the expressing 2+3, so my doubts are:
    (a) Is it appending any pseudo-column to the table with 2+3 getting evaluated to 5There's no pseduo-column involved. (Pseudo-columns are something that Oracle provides for you, without you having to spell out what you want. ROWID and LEVEL are examples of pseudo-columns. In this example, 2+3 is an Expression . Like pseudo-columns, expressions can usually appear in the ORDER BY clause, even though they are not actually stored in the table.)
    It's sorting first by the NUMBER 5 (= 2 + 3), not the 5th column. Since the NUMBER 5 has the same value on every row, every row ties for first place. The result of sorting by any constant is the same; the results are the same as not including that exrpression in the ORDER BY clause. That is the ORDER BY clause you posted is equivalent to
    ORDER BY  2 + 3
    ,         'foo'
    ,         SYSDATE
    ,         NULL
    ,         stu_idand it's also equivalent to
    ORDER BY  stu_idNone of the expressions except stu_id vary from row to row, so none of them affect the sorting.
    (b) If there exist a 5th column in the table student and we specify it in the select statement's select list (5 column names) then why its not considering it as 5 and sorting the data according that?As Solomon said, only number literals are taken to mean a column. 5 is a number literal, so
    ORDER BY  5means "sort by the 5th column", but 2 + 3 is not a literal (it's an expression that happens to include a couple of literals), so
    ORDER BY  2 + 3does not refer to the 5th colunmn.
    (c) Is it true that, any expression we write is getting evaluated to NULL? Then is it that ORDER BY NULL evaluates to no ordering and the parser searches for next column-name or position (if specified) ?No, when you way "ORDER BY x", the rows with lower values of x come first, followed by rows with higher values of x. Rows with the same value of x will be together, in no particular order with respect to each other (unless there is a tie-breaker expression later in the ORDER BY clause.
    That's exactly what happens when you say "ORDER BY NULL". NULL has the same value (actually, the same lack of any value) on all rows, so all the rows have the same value of x, and they will appear in no particular order.
    (d) if neither then, what's the reason of the ignorance?

  • Conditional order by clause with multiple columns

    I would like to know whether it is possible to include multiple columns in a conditional order by clause.
    Ex: I have written the following PL / SQL :
    CREATE PROCEDURE GetProducts
    @OrderBy VARCHAR(50),
    @Input2 VARCHAR(30)
    AS
    BEGIN
    SET NOCOUNT ON
    SELECT Id, ProductName, Description, Price, Quantity
    FROM Products
    WHERE ProductName LIKE @Input2
    ORDER BY
    CASE               
    WHEN @OrderBy = 'ProductNameAsc' THEN ProductName
    END ASC,
    CASE
    WHEN @OrderBy = 'ProductNameDesc' THEN ProductName
    END DESC
    END
    Now I want to include when the Orderby - "Productnameasc" then order by productname, price, stdate
    else
    orderby productname, crdate, category
    Could this be done? I tried it, but couldn't get this to work.
    Any help is greatly appreciated.

    Since matching ORDER BY columns have different data types (first column for CLERK is sal - number, first column for MANAGER deptno is number but first column for "else" is a string) we need to convert number to string but preserve number sort order. Since DEPTNO is NUMBER(2) we will use TO_CHAR with format 'S00'. Since SAL is NUMBER(7,2) we will use TO_CHAR with format model 'S00000D00'. For EMPNO we will use TO_CHAR with format model 'S0000'.
    select  deptno,
            empno,
            ename,
            job,
            sal
      from  emp
      order by case job
                 when 'CLERK' then to_char(sal,'S00000D00')
                 when 'MANAGER' then to_char(deptno,'S00')
                 else ename
               end,
               case job
                 when 'CLERK' then to_char(deptno,'S00')
                 else job
               end,
               case job
                 when 'CLERK' then job
                 when 'MANAGER' then to_char(empno,'S0000')
               end
        DEPTNO      EMPNO ENAME      JOB              SAL
            20       7369 SMITH      CLERK            800
            30       7900 JAMES      CLERK            950
            20       7876 ADAMS      CLERK           1100
            10       7934 MILLER     CLERK           1300
            10       7782 CLARK      MANAGER         2450
            20       7566 JONES      MANAGER         2975
            30       7698 BLAKE      MANAGER         2850
            30       7499 ALLEN      SALESMAN        1600
            20       7902 FORD       ANALYST         3000
            10       7839 KING       PRESIDENT       5000
            30       7654 MARTIN     SALESMAN        1250
        DEPTNO      EMPNO ENAME      JOB              SAL
            20       7788 SCOTT      ANALYST         3000
            30       7844 TURNER     SALESMAN        1500
            30       7521 WARD       SALESMAN        1250
    14 rows selected.
    SQL>  SY.

  • Writing order by clause with user parameter

    I have a user parameter where the user is supposed to choose what column they want to sort by.
    And they can choose between k.personnr and k.personnavn. I am trying to do this with a decode function.
    Now this would work fine if there was no union between these select statements.
    But with the union I get a ORA-01785, where they tell me to put in a number.
    Here is the sql:
    SELECT
    k.personnr as PERSON ,
    k.personnavn as NAVN,
    r.belop as SUM,
    concat(to_char(r.bilagdato,'MM'), to_char(r.bilagdato,'YYYY')) AS MND,
    PERIODE(concat(to_char(r.bilagdato,'MM'), to_char(r.bilagdato,'YYYY'))) AS PERIODE
    FROM
    reskontro r,
    klient k,
    kontoplan p,
    konto c
    WHERE
    r.distriktnr='21'
    and r.distriktnr=c.kontoid
    and r.distriktnr=k.distriktnr
    and r.personnr=k.personnr
    and r.kontonr=p.kontonr
    and (((r.bilagdato between :p_fra_dato and :p_til_dato) and (:p_fra_dato <= c.overfort) and (:p_til_dato <= c.overfort))
    or ((r.bilagdato between :p_fra_dato and c.overfort) and (:p_fra_dato <= c.overfort) and (:p_til_dato >= c.overfort)))
    UNION ALL
    SELECT
    k.personnr as PERSON ,
    k.personnavn as NAVN,
    (t.belop/100) as SUM,
    concat(to_char(t.bilagdato,'MM'), to_char(t.bilagdato,'YYYY')) AS MND,
    PERIODE(concat(to_char(t.bilagdato,'MM'), to_char(t.bilagdato,'YYYY')),:P_HORISONTAL) AS PERIODE
    FROM
    transaksjon t,
    klient k,
    kontoplan p
    WHERE
    t.distriktnr='21'
    and t.distriktnr=k.distriktnr
    and t.personnr=k.personnr
    and t.kontonr=p.kontonr
    and t.bilagdato between :p_fra_dato and :p_til_dato
    This is the order by clause I would like to use:
    order by decode(:p_order_by,'Personnavn',k.personnavn,k.personnr)
    I also get an error when I use:
    order by decode(:p_order_by,'Personnavn',2,1)
    Can anybody tell me how to work around this problem?

    Hi,
    One way you can do to get around this problem could be :
    select * from (
    SELECT
    k.personnr as PERSON ,
    k.personnavn as NAVN,
    r.belop as SUM,
    concat(to_char(r.bilagdato,'MM'), to_char(r.bilagdato,'YYYY')) AS MND,
    PERIODE(concat(to_char(r.bilagdato,'MM'), to_char(r.bilagdato,'YYYY'))) AS PERIODE
    FROM
    reskontro r,
    klient k,
    kontoplan p,
    konto c
    WHERE
    r.distriktnr='21'
    and r.distriktnr=c.kontoid
    and r.distriktnr=k.distriktnr
    and r.personnr=k.personnr
    and r.kontonr=p.kontonr
    and (((r.bilagdato between :p_fra_dato and :p_til_dato) and (:p_fra_dato <= c.overfort) and (:p_til_dato <= c.overfort))
    or ((r.bilagdato between :p_fra_dato and c.overfort) and (:p_fra_dato <= c.overfort) and (:p_til_dato >= c.overfort)))
    UNION ALL
    SELECT
    k.personnr as PERSON ,
    k.personnavn as NAVN,
    (t.belop/100) as SUM,
    concat(to_char(t.bilagdato,'MM'), to_char(t.bilagdato,'YYYY')) AS MND,
    PERIODE(concat(to_char(t.bilagdato,'MM'), to_char(t.bilagdato,'YYYY')),:P_HORISONTAL) AS PERIODE
    FROM
    transaksjon t,
    klient k,
    kontoplan p
    WHERE
    t.distriktnr='21'
    and t.distriktnr=k.distriktnr
    and t.personnr=k.personnr
    and t.kontonr=p.kontonr
    and t.bilagdato between :p_fra_dato and :p_til_dato)
    order by decode(:p_order_by,'Personnavn', NAVN, PERSON)
    /Uffe

  • ViewObjects Order by clause with DECODE

    Hello!
    I am using Jdeveloper 11g, version 11.1.1.2.0.
    The problem I'm having is this.
    If I use a DECODE statement in view objects ORDER BY clause, I get an error: "java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 2".
    Let me give an example. I'll be using EmployeesView view object, which is using Employees entity from HR schema.
    This is a part of view objects XML.
    <ViewObject
    xmlns="http://xmlns.oracle.com/bc4j"
    Name="EmployeesView"
    Version="11.1.1.55.36"
    SelectList="Employees.EMPLOYEE_ID,
    Employees.FIRST_NAME,
    Employees.LAST_NAME,
    Employees.EMAIL,
    Employees.PHONE_NUMBER,
    Employees.HIRE_DATE,
    Employees.JOB_ID,
    Employees.SALARY,
    Employees.COMMISSION_PCT,
    Employees.MANAGER_ID,
    Employees.DEPARTMENT_ID"
    FromList="EMPLOYEES Employees"
    BindingStyle="OracleName"
    CustomQuery="false"
    PageIterMode="Full"
    UseGlueCode="false"
    OrderBy="Employees.MANAGER_ID">
    As you can see in this case, the Order by clause is very simple. This works like a charm.
    But, if put something like this "DECODE(Employees.MANAGER_ID, NULL, 1, 2)" in the Order by, I get an internal parsing error.
    I replicated this error on my home machine as well as on my work machine. I'm using the same version of Jdeveloper on both.
    Has anyone else stumbled upon this problem and solved it?
    Any thoughts would be greatly appreciated :)
    Kristjan

    The second example works, but the first one doesn't, unfortunately :/
    Also, the example I gave is unfortunately just that, a proof-of-concept example that there is a problem with DECODE if it is written inside the Order by clause.
    My real DECODE use case is a bit different. Like this: "DECODE(attribute, 'N', 1, 2) ASC".
    Since posting my original question, I did some research-by-example work and I discovered that this is not just a problem of DECODE, but more like a problem of brackets and commas.
    No database function that uses more than one parameter can be used in Order by clause.
    The reason is, if a function with more than one parameter is used, commas inside brackets have to be used. Something along the lines of: "database_function(param1, param2, ...)".
    The parser seems to have a problem with this kind of expressions.
    Is there a work around?
    Kristjan
    p.s.: Thank you for your quick response.

  • Where to place ORDER BY clause when a query includes UNION

    I have a query that has UNION in it. could you please tell me where to place the ORDER BY clause. Because it's throwing an error if i place the ORDER BY clause at the end

    Because you are using the UNION set operator, you need to either specifically list your columns or use positional notation.
    Without a set operator we can order by the column name without specifically listing it:
    SQL> select * from dual
      2  order by dummy;
    D
    X
    1 row selected.This doesn't work once you introduce a set operator:
    SQL> ed
    Wrote file afiedt.buf
      1  select * from dual union all
      2  select * from dual union all
      3  select * from dual
      4* order by dummy
    SQL> /
    order by dummy
    ERROR at line 4:
    ORA-00904: "DUMMY": invalid identifierSo you need to either use positional notation:
    SQL> ed
    Wrote file afiedt.buf
      1  select * from dual union all
      2  select * from dual union all
      3  select * from dual
      4* order by 1
    SQL> /
    D
    X
    X
    X
    3 rows selected.Or, specifically list or alias the columns you are projecting:
    SQL> ed
    Wrote file afiedt.buf
      1  select dummy from dual union all
      2  select dummy from dual union all
      3  select dummy from dual
      4* order by dummy
    SQL> /
    D
    X
    X
    X
    3 rows selected.
    SQL> ed
    Wrote file afiedt.buf
      1  select dummy as d from dual union all
      2  select dummy as d from dual union all
      3  select dummy as d from dual
      4* order by d
    SQL> /
    D
    X
    X
    X
    3 rows selected.cheers,
    Anthony

  • Need help with named query for 1-to-many entities

    Hi all,
    I'm in desperate need of a query and I can't seem to figure it out.
    Here's the situation:
    I have 2 entities in a one-to-many relationship. One ServerInstance to Many AppUrl's related by a join table
    @Entity
    public class ServerInstance implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Integer id;
    private String instancename;
    private String description;
    private String home;
    private String hostname;
    private String hostname_front;
    private String ipfront;
    private String ipback;
    private String os;
    private String layer;
    @OneToMany (fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
    private List<AppUrl> appUrl = new ArrayList<AppUrl>();
    @Entity
    public class AppUrl implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private Integer id;
    private String appurl;
    private String description;
    private String keyword;
    private Integer priority;
    private String curlresult;
    In the underlying database they are mapped by the table T_SERVERINSTANCE_T_APPURL
    What I need is a named query in the ServerInstance entity to find any AppUrl where curlresult = 'down'
    I tried the following:
    @NamedQuery
    (name = "findDownInstances", query = "SELECT i FROM ServerInstance i WHERE i.appUrl.result = 'down')
    This gave me the following error:
    invalid navigation expression [i.appUrl.result], cannot navigate collection valued association field [appUrl].
    Is there any way to create a query which will do what I want?
    Thanx in advance!

    can you provide the equivalent SQL (not JPQL!) query that you want, based on tables T_SERVERINSTANCE and T_APPURL, so that there are no misunderstandings ?

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

    I have the following sample data:
    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 query below gives me exactly what I want, in the order I want it. However, I am wondering if there is a way to get this order without creating the SEQ column, since I don't need it 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

    Hi,
    As long as there's only one root, you can say ORDER SIBLINGS BY, but you can't do that in a sub-query (well, you can, but usually there's no point in doing it in a sub-query). If the CONNECT BY is being done in a sub-query, there is no guarantee that the main query will preserve the hierarchical order that the sub-query provides.
    The query you posted doesn't require a suib-query, 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 doesn't require a sub-query. It also doesn't require dual, so I suspect what you posted is a simplification of what you're really doing, and that may need a sub-query. In particular, if you intend to GROUP BY part_nbr, then you need the sub-query. We can repeat the CONNECT_BY_ROOT expression in the WHERE clause (or, now that I think about it, use a START WITH clause instead of WHERE), but, for some reason, we can't use CONNECT_BY_ROOT in a GROUP BY clause; we need to compute CONNECT_BY_ROOT in a sub-query, give it a name (like part_nbr), and GROUP BY that column in a super-query.
    This assumes that there is only one root node. ORDER SIBLINGS BY means just that: children of a common parent will appear in order, but the root nodes, who have no parents, will not necessarily be in order.
    Here's what I meant by using START WITH instead of 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 efficient, because it narrows down the results before you waste time getting their descendants.
    Using a START WITH clause here is analagous to me sending you an e-mail, saying "Come to a meeting a my office at 3:00."
    Using a WHERE clause here is analagous to me sending an e-mail to everyone in the company, saying "Come to a meeting a my office at 3:00", and then, as people get here, telling everyone except you that they can go back.
    ORDER SIBLINGS BY was introduced in Oracle 9.
    Edited by: Frank Kulash on Dec 9, 2010 2:39 PM
    Added version with START WITH clause

  • Different Ordered Result-Sets With Same Query.

    I am executing a very simple query which returns a name and an id. It is order by name preaty simple.
    BUT. returs different if the framework is english or french.
    <?xml version="1.0" standalone="yes"?>
    <NewDataSet>
    <Table>
    <DATAUNITID>11920</DATAUNITID>
    <NAME>(FR) Atlantis</NAME>
    </Table>
    <Table>
    <DATAUNITID>11922</DATAUNITID>
    <NAME>(FR) Beaumont</NAME>
    </Table>...
    ========================================================
    <?xml version="1.0" standalone="yes"?>
    <NewDataSet>
    <Table>
    <DATAUNITID>12006</DATAUNITID>
    <NAME>AVRANCHES</NAME>
    </Table>
    <Table>
    <DATAUNITID>12005</DATAUNITID>
    <NAME>CARENTAN</NAME>
    </Table>
    Any thoughts?
    Thanks in advance,
    Frank

    Hi Satria,
    You can detach the query in Bex analyser.
    Once you open the workbook, right click context menu,
    has the option to delete the query from work book.
    The query can be reinserted again.
    However a better solution would be to make the format changes in the workbook properties and save the changes.
    Regards,
    Nitin

Maybe you are looking for

  • Version 8 stopped working on my Windows 7 computer

    Can I download an older version of Firefox. V8 has stopped working completely on my Windows 7 machine. An older computer in the house, running an older version of Firefox is working just fine. Or any further suggestions on what to do since I have tri

  • Read Fixed length file

    I have a text file that has data in specific positions of the file. ie. Pos 1-20 Name Pos 21-30 Division Pos 31-38 Birthdate I saved the file in the DB and want to process it to read the data in the specific positions I listed above. I started with t

  • Thread death and xml files when analyzing large datasets

    i analyze large data sets. for example: 4000 persons that each have a time series with 8,000 data points. i do this linearly, so (i think) i am only running the *public static void main(String[] args) { .... }* for(Person person : PersonSet) {  // th

  • Flash installer wont event start

    i was trying to update my flash player because mozilla is starting to be unable to fully view some sites. i downloaded the installer but it wont start. i double clicked and nothing happened. nothing at all, not even an error message. i also tried uni

  • I have Photoshop CC 2014 the one with Lightroom and I am having problems with Photoshop crashing after about 5 minutes?

    After about 5 minutes of Photoshop CC 2014 running it crashes, i have tried running it as an administrator but still crashes.