Can i restrict the number of rows in Connect by clause

Hi,
I have atable with data with two columns as
MAIN SUB
9 10
9 11
11 13
12 13
The query which i am using
SELECT Main,Sub
FROM My_Tab
START WITH Main = 9
CONNECT BY PRIOR Sub= Main
gives
9 10 also in the result
My question is can i restirct the output by specifying the the child eg in case 13
so that i dont get a row in the output with 9 10 in it.
Thanks

Nikhil Juneja wrote:
My question is can i restirct the output by specifying the the child eg in case 13
so that i dont get a row in the output with 9 10 in it.
Can you explain this please...
Do you mean..
if you give like child is 13 in your query, then it should give only nodes which has 13 as their childs??
with tab as
  select 9 MAIN,10 SUB from dual union all
  select 9 MAIN,11 SUB from dual union all
  select 11 MAIN,13 SUB from dual union all
  select 12 MAIN,13 SUB from dual
SELECT Main,Sub
FROM tab
START WITH sub=13
CONNECT BY  Sub=PRIOR Main is this??
Ravi Kumar

Similar Messages

  • How can I limit the number of rows returned by a select stat

    How can I limit the number of rows returned by a select
    statement. I have a query where I return the number of stores
    that are located in a given area.. I only want to return the
    first twenty-five stores. In some instances there may be over
    200 stores in a given location.
    I know is SQL 7 that I can set the pagesize to be 25....
    Anything similiar in Oracle 8i?
    null

    Debbie (guest) wrote:
    : Chad Nale (guest) wrote:
    : : How can I limit the number of rows returned by a select
    : : statement. I have a query where I return the number of
    : stores
    : : that are located in a given area.. I only want to return the
    : : first twenty-five stores. In some instances there may be
    : over
    : : 200 stores in a given location.
    : : I know is SQL 7 that I can set the pagesize to be 25....
    : : Anything similiar in Oracle 8i?
    : If you are in Sql*Plus, you could add the statement
    : WHERE rownum <= 25
    : Used together with an appropriate ORDER BY you
    : could get the first 25 stores.
    Watch out. ROWNUM is run before ORDER BY so this would only
    order the 25 selected
    null

  • How can i now the number of rows afected by the last query?

    how can i now the number of rows afected by the last query?
    For example:
    i made this update :
    update trl_trial set status = 1 /* Validation */
    where trial_id = cobject_id
    and status = 0; /* Initial */
    if NUMBERS_OF_ROWS = 0 then
    end if;
    how can i do this?
    thank u!!!!

    how can i now the number of rows afected by the last query?
    For example:
    i made this update :
    update trl_trial set status = 1 /* Validation */
    where trial_id = cobject_id
    and status = 0; /* Initial */
    if NUMBERS_OF_ROWS = 0 then
    end if;
    how can i do this?
    thank u!!!! Do the following :
    update trl_trial set status = 1 /* Validation */
    where trial_id = cobject_id
    and status = 0; /* Initial */
    if(SQL%ROWCOUNT = 0 ) then
    else
    end if;
    you can also declare a variable and do
    myvar := SQL%ROWCOUNT;
    SQL%ROWCOUNT returna the # of rows afected by any sql
    statement, like DELETE, UPDATE

  • Can I limit the number of rows returned on a Select?

    Can I limit the number of rows returned on a Select statement? I would be using JDBC in a Java program.

    Use Java prepared statements with the equivalent of this SQL*plus script:
    VARIABLE n number
    EXEC :n := 3;
    SELECT rownum FROM all_objects WHERE rownum <= :n;
        ROWNUM
             1
             2
             3
    EXEC :n := 5;
    SELECT rownum FROM all_objects WHERE rownum <= :n;
        ROWNUM
             1
             2
             3
             4
             5

  • Can we find the number of rows in table from the dump file

    Hi All,
    Can we find the number of rows in table from the dump file with out importing the table in to the database?
    Please let me know ,if any option is there.
    Thanks,
    Kumar.

    <s>Try to import with option SHOW=Y, that should skip the number of rows which are into a table from a dump file.</s><br>
    <br>
    Nicolas.<br>
    Oops, sorry, that doesn't show the number of lines...<br>
    Message was edited by: <br>
    N. Gasparotto

  • How can I restrict the number of emails in iOS 7?

    In the previous versions of iOS you could indicate how much emails you wanted to store on your iPhone. Now in iOS 7 that option is gone.
    I don't want to clogg my iPhone whit all my emails.
    What can I do to restrict the number of emails?

    Other than changing to an IMAP or Exchange account, you can't. The feature you're referring to was removed in iOS 7.0.

  • How can I get the number of rows in my sql result, without a loop?

    Hello,
    I've a problem, I would like to get the number of rows in my sql result without make a loop like :
    while (rs.next()){
    int number = rs.getRow();
    Is there any method to do this, on the first element?
    Thx, STeF

    If you want to count how many rows are in result set, I dont think you can, but you could always run a count statement for that sql
    say your sql is
    select field1, field2, field3
    from table1, table2
    where field4=field5 ......
    then you can count the rows this statement returns by
    select count(*) from
    (say your sql is
    select field1, field2, field3
    from table1, table2
    where field4=field5 ......)
    This way you will get the count for just that sql

  • Urgent******how can i get the number of rows enterd by the user in a table

    Hi Frndz..
    As per my requirement i need to do the validations for the multipple rows in a table that was enterd by the user,
                   T
              The prob is how can i get that number of rows that enterd by user,
           WDMessageManager msg = wdComponentAPI.getMessageManager();
         String col1= "";
         String col2= "";
         double col3= 0;
         double col4= 0;
         double amount= 0;
         int nodesize = wdContext.nodeTest().size();
         try
         for(int i=0; i<=2 ; i++)
                   col1 = wdContext.nodeTest().getTestElementAt(i).getCol1();
                 //msg.reportSuccess("col1 size is :"+col1);
                   col2 = wdContext.nodeTest().getTestElementAt(i).getCol2();
                   col3 = wdContext.nodeTest().getTestElementAt(i).getCol3();
                   col4 = wdContext.nodeTest().getTestElementAt(i).getCol4();
                    amount = wdContext.nodeTest().getTestElementAt(i).getAmount();
              if(col1 == "" )
                        msg.reportException("Plz fil the col1 for line:",true);
                   break;
              else
              if(col2 == "" )
                                  msg.reportException("Plz fil the col2 for line:",true);
                             break;
                        else
              if(col3 <= 0)
                   msg.reportException("Plz fil the col3:",true);
                   break;
              else
                   if(col4 <= 0)
                   msg.reportException("Plz fil the col4:",true);
                   break;
              msg.reportSuccess("skvgjhdfgasdfgsjkafguisafisenvtvyeriy");
                                                       wdThis.test();
         catch (Exception e)
                   msg.reportException("strMessage in catch block",true);
         this is the code am going
    Regards
    Rajesh

    Hi,
       You can try this:
    * Let's say the table's datasource is a node called Table  and it has two attributes first & second.
    * You want to check if any of these attributes has been changed by the user or not. If they have been
    * changed then you want to do some validations against them.
      int sizeOfTable = wdContext.nodeTable().size();
      for(int i = 0; i < sizeOfTable; i++){
         IPrivate<view name>.ITableElement ele = wdContext.nodeTable().getTableElementAt(i);
         if(ele.isChangedByClient(ITableElement.<attribute name>)){
            //value has been changed, do some validation. You can get the row index using ele.index().
    Regards,
    Satyajit.

  • Can I "count" the number of rows excluding the header and footers

    I have some tables that consist of a different number of rows, as the number is part of an equation I need to know the number of rows excluding the header and footers. I have the work around in =ROWS(ColumnG)-3, but is there a tidier way? I want to be able to add footers (or headers) too and not have these counted.
    Many thanks
    Lee

    Hi Lee,
    Add a column to your table (for purposes of this discussion, the new column is placed before column C, and becomes the new column C). enter the formula below in all regular cells, but NOT in header or footer cells:
    =1
    Use the formula below, placed anywhere (except in a regular cell in column C) to get the number of non-header, non-footer cells:
    =COUNT($C)
    The first formula will automatically be placed in cells added to column C, and the results will change to reflect the added rows.
    Regards,
    Barry

  • How can I limit the number of rows in Oracle?

    Hi All,
    I am using very complex query where I join 6 table to fetch data from database.
    I have requirement like fetching a first 10000 row and then fetching another records after 10000 and so on.
    I just want to know how to fetch a limited number of rows using sql query. Moreover, I also want to know how to calculate the total number of row (alternative of count method because I don't want to query the database twice because its affect the performance).
    Thanks in advance.
    Regards,
    Sunny

    sunny@oimnewbie wrote:
    Hi All,
    I am using very complex query where I join 6 table to fetch data from database.
    I have requirement like fetching a first 10000 row and then fetching another records after 10000 and so on.
    I just want to know how to fetch a limited number of rows using sql query. Moreover, I also want to know how to calculate the total number of row (alternative of count method because I don't want to query the database twice because its affect the performance).
    Thanks in advance.
    Regards,
    SunnyThis smells like a very fishy requirement based on a fundamental misunderstanding of how Oracle works. Could you explain why you want to arbitrarily limit the result set to 1000 rows? What will happen between that and getting the "next" 1000? What triggers getting the "next" 1000? and how do you define "next", since there is no ordering in a heap table.
    I suspect we can make that requirement go away be presenting a better approach to the real issue.

  • Restrict the number of rows in XML publisher

    Hi All,
    I have report which has header and lines. I want to display all the lines corresponding to an header in one page in xml publisher. Please suggest.
    Thanks and Regards,
    Mahesh

    I got the solution. We have to use page break <?split-by-page-break:?> after the layout.
    Thanks and Regards,
    Mahesh

  • Can i get a number of rows in the select list??

    Hello~
    I am studying the "oracle call interface". but i don't know much about oci.
    Anyway i want to know that how can i get a number of rows.
    for example, there is a source code of the number of colums in the select list.
    The following is a list of DB(example)
    /*DB table*/
    ID NAME CODE ID
    1 A 1 A
    2 B 2 B
    /*source*/
    err = OCIAttrGet ((dvoid *) stmhp, (ub4)OCI_HTYPE_STMT, (dvoid*)
    &parmcnt, (ub4 *) 0, (ub4)OCI_ATTR_PARAM_COUNT, errhp);
    /*result*/
    The Column is 4. (ID, NAME, CODE, ID)
    So, i think that the row is 3 (ID, 1, 2) in the DB table.
    Simply, Can i get a number of rows in the select list??
    for example,
    err = OCIAttrGet ((dvoid *) stmhp, (ub4)OCI_HTYPE_STMT, (dvoid*)
    &parmcnt, (ub4 *) 0, (ub4)OCI_ATTR_RAW_COUNT, errhp);
    I'm trying to get the number of row count. but i can't find.
    Please, could you let me know that how can i get the number of row count.
    Thank you.

    Thank you for your reply.
    we are tested the source code by reply.
    The following is the test source code.
    /*source code*/
    strcpy (szStatement, "SELECT * from DB_TABLE");
    OCIStmtPrepare(gpOCIReadStmHandle, gpOCIErrHandle, szStatement,
         strlen(szStatement), OCI_NTV_SYNTAX, OCI_DEFAULT);
    OCIStmtExecute(gpOCISvcHandle, gpOCIReadStmHandle, gpOCIErrHandle,
         0, 0, 0, 0, OCI_DEFAULT);
    /* get a number of rows count , Reply : prajithparan*/
    OCIAttrGet((dvoid *)gpOCIReadStmHandle, OCI_HTYPE_STMT, (dvoid *)&nRowCount, NULL, OCI_ATTR_ROW_COUNT, gpOCIErrHandle))
    But There is a problem of the result value.
    The result value is 0. It's mean that the row count is 0. and then we are using the all of fuction is succeed.(return value)
    I don't know what is problem. Please let me know about the problem and solution.
    Thank you.

  • Increase the number of rows in MDXTEST

    Dear colleagues,
    I use the SAP transaction MDXTEST to test MDX queries generated by WebI reports. The expected result set is significantly larger then 500 rows which causes the following error in MDXTEST:
    "There are more than 500 possible inputs
    Message no. DH803"
    The help message also says:
    "With the function 'Restrict values' you can define selection conditions that reduce the number of valid values.
    Use the same function to change the maximum number of rows to be displayed."
    Can you explain what that means - how can I increase the number of rows retrieved?
    Do I have to modify the MDX statement and if so, how?
    Is there a menu option or customizing setting for this purpose?
    Any help is appreciated.
    Regards
    Johannes

    Official reply from SAP Support: Please be aware that MDXTEST is only a test transaction. Therefore, the display of data has been restricted and you cannot change this.

  • How do you restrict the number of table columns on the data tab?

    I have a table with 50+ columns. Is it possible to restrict the list of columns on the data tab to say 5 columns as I'm only interested in seeing/updateing the data for these 5 columns. You can restrict the number of rows using the filter but not the columns. Is there some other way seeing an updateable "view" of the table? I suppose you could create a number of views and edit through them but there are too many combinations.
    regards
    Paul P

    I don't know of any way of reducing the number of columns that display in the Table data grid.
    However, you can rearrange the columns to have the five columns you want to edit as the first five. With fifty columns, even this would be some effort to find and drag them to the left of the view, but it should give you the five columns you want to update on the window at the same time.

  • Restrict the no. of rows entered in select-options

    Dear ABAPers,
    I have used CALL FUNCTION 'SELECT_OPTIONS_RESTRICT' to only allow user key in single value. The field is BUKRS(Company Code). Can I restrict the number of company code entered by user in this select-option? Please advise.
    Thanks in advance.
    Best Regards,
    Hikaruno

    Sure, just do a check in the AT SELECTION-SCREEN event.
    at selection-screen.
    data: lines type i.
    describe table s_bukrs lines lines.
    if lines > 10.
      message e001(00) with 'More than 10 entries'.
    endif.
    Regards,
    RIch Heilman

Maybe you are looking for

  • Home Sharing setup for 2 pc, 2 iPhone & an iPad

    Hello everyone! I am really hoping someone can help me. My mom and I just got iPhone 5s and I would like to be able to share my iTunes music with her, but I am not sure how to set this up. I have reviewed many posts here, but they are all different d

  • Un muting blinking mute buttons

    I don't know how I did this, but can't seem to un-mute them!

  • Compressing movie for the web

    Hello All! Im fairly new to director but have lots of experience with flash. Hope it will become handy I have eLearning movie that I plan to distribute over the internet but the published dcr is 22mb which is not ideal for preloading. I guess that I

  • Cannot get high transfer rates with PCI-6534

    I am using a PCI-6534 in the Pattern I/O mode for performing data acquisition. The data rate I am getting for reliable data is about 2MS/s. I need 8MS/s, but do not get reliable or correct data at this rate. According to the 653X User Manual the benc

  • HT6114 After updating macbook pro to 10.9.2 my system is extremely slow

    After updating my macbook pro 2011 to 10.9.2 my system is running so slow it is unusable.  After restart with no other app running system memory is completely used up. Memory gets down to about 20 mb and even mouse usage is slow.    Should I go throu