Counting number of rows that resides in a partition/subpartiton

Hi,
I need to get the number of rows from a subpartition named (G2EDC_LOG_200704_20070407 ) in edc_log_test . Here is the below query which I am going to use to get the count of records.
Also I need to know if I can combine this query with out using UNION ALL.
Thanks in advance.
Jay
SELECT count(el.batch_nbr)
FROM edc_log_test el,
edc_batch_test eb
WHERE el.batch_nbr = eb.batch_nbr
AND eb.status IN ('SUSPENDED' ,'BALANCED' )
AND (eb.user_status = 'CLOSED'
OR eb.user_status IS NULL)
AND TO_CHAR(capture_date,'YYYYMMDD') >= sysdate - 60
AND nvl(do_not_remit, 0) <> 0
UNION ALL
SELECT count(el.batch_nbr)
FROM edc_log_test el,
edc_batch_test eb
WHERE el.batch_nbr = eb.batch_nbr
AND eb.status IN ('SUSPENDED')
AND eb.user_status IN ('NEW', 'OPEN')
AND TO_CHAR(capture_date,'YYYYMMDD') >= sysdate - 365
AND nvl(do_not_remit, 0) <> 0

SQL> select count(1) from test_table;
COUNT(1)
1000
SQL> select count(1) from test_table partition(sys_p21);
COUNT(1)
122
SQL> select count(1) from test_table partition(sys_p22);
COUNT(1)
244
SQL> select count(1) from test_table partition(sys_p23);
COUNT(1)
261
SQL> select count(1) from test_table partition(sys_p23) where test_id=994;
COUNT(1)
1
SQL> select count(1) from test_table partition(sys_p23) where test_id=993;
COUNT(1)
0
SQL> select count(1) from test_table partition(sys_p23) where test_id between 900 and 1000;
COUNT(1)
24
SQL>

Similar Messages

  • How to count number of rows in table

    can I get number of row in table except Count(*) in pl/sql
    is there any other way

    Also posted and answered here
    how to count number of rows in table
    count(*) will be the fastest way. It is only slow if the table has a vast number of rows, in which case why do you need to know the tables has 73552436467721 rows and not 73552436467737 rows. It doesn't seem to be much use. Either that or you are counting them a lot, which again seems rather pointless.

  • How to set the number of rows that an awt.Choice can display

    Dear Sir,
    I want to ask how an awt.Choice  can set the number of rows that it can display, like the method setMaximumRowCount in JCombobox. Since I want to set more row can be displayed, but choice no any method can set. And I have tried to add Jcombobox into awt.frame, then, the handling event function cannot receive event for the right-top cornet button(minimize, maximum, close).
    Best Regards,

    please post a Short, Self Contained, Correct Example showing your problem.
    bye
    TPD

  • Need help to count number of rows and display in file

    Hello,
    my scenario is IDOC to File......i am using XSLT mapping and using FCC parameters to convert the flat file.
    now new requirement is i need to count number of rows and add count value last of the file.
    Please let me know how to do it,
    thanks in advance for your help.
    Regards,
    Chinna

    thanks again, one more Q.
    in XSLT mapping i have written for loop for complete structure.
    example : <Details>
                         <node1>
                         <node2>
                   </details>
    in XSLT mapping
                         <xsl:for-each select="ZMATMAS_01/IDOC/E1MARAM">
         <Details>
         </Details>
         </xsl:for-each>
    if i add the field at target side....then i will come under details node and it will be repeated.
    how to declare in XSLT mapping.

  • Count number of rows in table

    Hi!
    1. How can you through ABAP and select statements count the number of rows in one table?
    2. I want to read all rows from one table to an internal table. Can this be done dynamically or do I first have to count the number of rows in the table and then declare an internal table with the number of rows counted.
    regards
    Baran

    HI,
    No you don't have to count number of rows first, Internal table size will increase dynamically. you have to declare this with initial size like this.
    <b>data: itab type standard table of bkpf initial size 0.
    SELECT * FROM bkpf into table itab.</b>
    All values from bkpf will be inserted into table internal table itab.
    Regards,

  • How to add the Row count(number of rows in table)  in  the table header?

    Hi,
    I'm having a table. This table is viewed when i click on a search button.
    <b>On the table header it should dynamically display the number of rows in the table, i.e., the row count.</b>
    How to do this? could any one explain me with the detailed procedure to achieve this.
    Thanks & Regards,
    Suresh

    If you want to show a localized text in the table header, you should use the <b>Message Pool</b> to create a (parameterized) message "tableHeaderText" like "There are table entries".
    Next, create a context attribute "tableHeaderText" of type "string" and bind the "text" property of the table header Caption UI element to this attribute.
    Whenever the table data has changed (e.g. at the end of the supply function for the table's data source node), update the header text:
    int numRows = wdContext.node<TableDataSourceNode>().size();
    String text = wdComponentAPI.getTextAccessor().getText
      IMessage<ComponentName>.TABLE_HEADER_TEXT,
      new Object[] { String.valueOf(numRows) }
    wdContext.currentContextElement().setTableHeaderText(text);
    Maybe you want to provide a separate message for the case that there are no entries.
    Alternatively, you can make the attribute calculated and return the header text in the attribute getter.
    Armin

  • Count number of rows in a table

    Hi,
    I have a requirement. I want to frame a SQL, which takes schema name as input and returns tables owned by that schema and number of rows inside a particular table.
    A Sample output:
    ===========
    Table            No. of Rows
    ~~~~          ~~~~~~~~
    A                    123
    B                    126
    C                    234
    .Can somebody help me in framing a query for the same.
    Regards,

    hoek wrote:
    But you could use this script:
    http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
    Laurent's solution most likely was published before IOT. Anyway, IOT ovwerflow tables must be excluded. Otherwise:
    SQL> select  table_name,
      2          to_number(
      3                    extractvalue(
      4                                 xmltype(
      5                                         dbms_xmlgen.getxml('select count(*) c from '||owner || '.' || table_name)),'/ROWSET/ROW/C')) cou
      6    from  dba_tables
      7    where owner = 'OE'
      8  /
    ERROR:
    ORA-19202: Error occurred in XML processing
    ORA-25191: cannot reference overflow table of an index-organized table
    ORA-06512: at "SYS.DBMS_XMLGEN", line 176
    ORA-06512: at line 1
    no rows selected
    SQL> select  table_name,
      2          to_number(
      3                    extractvalue(
      4                                 xmltype(
      5                                         dbms_xmlgen.getxml('select count(*) c from '||owner || '.' || table_name)),'/ROWSET/ROW/C')) count
      6    from  dba_tables
      7    where owner = 'OE'
      8      and nvl(iot_type,'X') != 'IOT_OVERFLOW'
      9  /
    TABLE_NAME                          COUNT
    CUSTOMERS                             319
    WAREHOUSES                              9
    ORDER_ITEMS                           665
    ORDERS                                105
    INVENTORIES                          1112
    PRODUCT_INFORMATION                   288
    PRODUCT_DESCRIPTIONS                 8640
    PROMOTIONS                              2
    PRODUCT_REF_LIST_NESTEDTAB            288
    SUBCATEGORY_REF_LIST_NESTEDTAB         21
    10 rows selected.
    SQL>  SY.

  • Counting number of rows in a given ResultSet

    hi,
    suppose i have following code :
    ResultSet rs = stmt.executeQuery("Select EmailAddress FROM Customer");
    & i wanna know how many number of rows are there in this ResultSet
    .... how can i do that... is there any method i can use
    ... thanx in advance

    What I would do is:
    //suppose res is your resultSet object
    res.last();//move the cursor to the last row in the result set
    int numRows = res.getRow();//get the current row number
    ...Since you have already executed a query to the DB you can use this result set without having to execute an additional query of type:select count(*) from <tableName>Hope that helped.
    afotoglidis

  • Count number of rows

    is there a more elegant way to count the number of rows in a table. Only way I can think is to make a hidden column populated with the row numbers and then use a max function.
    thanks

    Thanks Yven - just the ticket.
    PW your suggestion was useful as I didnt know about the COUNTA function.
    I have a table that takes all it values via an Index calculation from a master table (selected by a check mark or number). As such it is possible to have more selected in the master list than rows are available in the View table. I can now add a warning that tells me more values have been selected than can be presented.
    I actually have four tables each representing a song set list for a performance and the master table is the complete list of songs to choose from. The reality is the size of the table isnt likely to change so I probably could use a fixed value but I always like to be flexible.
    The system works OK as I can drag the songs into different orders but gets a little messed up if I change the sort order of the master or add new entries. and if I decide a song needs to be in another set I have to go back to the master to change the cat code.
    I often think this would be a good idea for a piece of software especially when touch pads and screen become more popular. There is a nice little list software that demoed the iPhone capabilites in this idea.

  • Count number of rows from oracle and sql database and generate a report

    Hi All,
    Can someone help me in writing a java program for the following scenario?
    1. Read the number of rows available from oracle table and print the total row count in a Report.txt text file.
    2. Read the number of rows inserted in a sql database (after a specific process-just an information) and print the total row count in the same text file Report.txt .
    3. Read the Error Log file (which is generated after a specific process say it has success and failed report for each iterations) and print the number of success and number of failure in the same text file Report.txt .
    I need the final Report.txt file in the following format:
    1. Oracle table <table name> has 500000 rows.
    2. After completion of the specific process 300000 rows were added to SQL table <table name>
    Error Log Report:
    300000 successfull entries and 200000 failed entries were found from the Error Log file.

    Thanks for your immediate reply.
    I'm just a beginner in java so if i make any mistake please correct and excuse me. :)
    This is the code i have for connecting to two different database.
    package connectDatabase;
    * @author
    import java.sql.*;
    public class ConnectTo
         public void OracleDB()
              Connection dbconn;
              try {
                DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                String connString="jdbc:oracle:thin:@SYS_IP:1521:oracl";
                dbconn = DriverManager.getConnection(connString, "uname","pwd" );
            catch(SQLException sqlex)
                 sqlex.printStackTrace();
            catch(Exception excp)
                excp.printStackTrace();
         public void SqlDB()
              Connection conn;
              try { 
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
                String url = "jdbc:odbc:connectDB"; 
                conn = DriverManager.getConnection(url,"uname","pwd");  
              catch (Exception e)
                System.err.println("An Exception occured! " +e.getMessage()); 
    }I'm just codding the second half which is for connecting to oracle databse and calculates the row count and displayes in the command prompt.
    then connects to SQL database and counts successfull insert in the table.(row count) and displayes on the command prompt.
    can you simplify the above code so that i can call the oracleDB() method and SqlDB() method seperately from another calss file using the object of this class?
    I'm ok if the report can be seen in a command prompt. FInally i need to calculate the success and failure count from the log file. will let you know once i'm done with codding.

  • Count number of rows for TWO QUERIES USING MINUS OPERATOR

    I have the following piece of sql, i would like to know how could i programatically using plsql count the number of rows returned by the following statement. I know that %ROWCOUNT returns the rowcount for the last execute INSERT, UPDATE, DELETE and SELECT INTO statement. Any help is much appreciated thanks.
    select *
    from admt1m4.usr@tcprod u
    where u.authoriztion = 'Omf99FullUsage'
    and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug where ug.left in
    (select obid from admt1m4.usrgrp@tcprod g 
    where g.participant not in ('super user grp', 't1_WbsPSAnalystGrp')))
    and u.activeuser = '+'
    MINUS
    select *
    from admt1m4.usr@TCPROD u
    where u.authoriztion = 'Omf99FullUsage'
    and u.obid in (select right from admt1m4.usrtogrp@TCPROD ug
    where ug.usrgrpname in ('super user grp', 't1_WbsPSAnalystGrp'))
    and u.activeuser = '+'

    Hi,
    Have you tried
    SELECT COUNT (1) cnt
      FROM (SELECT *
              FROM admt1m4.usr@tcprod u
             WHERE u.authoriztion = 'Omf99FullUsage'
               AND u.obid IN (
                      SELECT RIGHT
                        FROM admt1m4.usrtogrp@tcprod ug
                       WHERE ug.LEFT IN (
                                SELECT obid
                                  FROM admt1m4.usrgrp@tcprod g
                                 WHERE g.participant NOT IN
                                          ('super user grp', 't1_WbsPSAnalystGrp')))
               AND u.activeuser = '+'
            MINUS
            SELECT *
              FROM admt1m4.usr@tcprod u
             WHERE u.authoriztion = 'Omf99FullUsage'
               AND u.obid IN (
                      SELECT RIGHT
                        FROM admt1m4.usrtogrp@tcprod ug
                       WHERE ug.usrgrpname IN
                                         ('super user grp', 't1_WbsPSAnalystGrp'))
               AND u.activeuser = '+')or your requirement is something else...
    *009*

  • Counting number of rows

    Hi guys,
    I am trying to count the number of rows using the following code:
    try{
    PreaparedStatement preparedStatementForOldTable = connection.createStatement("SELECT * FROM " + schemaName + "." + oldTableName, ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    ResultSet resultSetForOldTable = preparedStatementForOldTable.executeQuery();
    if (resultSetForOldTable.last()) {
         System.out.println("Number of rows:" + resultSetForOldTable.getRow());
         resultSetForOldTable.first();
    ............perform tasks
    } catch (SQLException se) {
    System.out.println("error:" + se.getMessage());
    but i'm always getting the exception UnsupportedOperationException can somebody help me out with this. Can u suggest any other way to count the rows.

    Hi,
    This error indicates that the requested operation is not supported. Your JDBC driver seems not to support it.
    Please let me know the version of the JDBC driver.
    Hope that helps.
    Best Luck!
    Senthil Babu
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Auto Counting Number of Rows Where Data is Entered

    I am trying to automatically count the number of rows where data is entered.  For example, I have a table with six open rows to enter information.  If only three of those rows (A2-A4) had names entered in them, and the next three rows were left blank, can I get each name to equal the value "1" so that I can get a total tally of how many names have been entered? So the final tally in this example would be "3." I appreciate your help!
    file:///Users/josephdlugo/Desktop/Screen%20Shot%202014-04-30%20at%2011.58.28%20A M.png

    there is a function, COUNTA(), that will count the number of items that are not empty:
    C1=COUNTA(B)
    this is shorthand for select cell C1, then type, or copy and paste the formula:
    =COUNTA(B)
    The COUNTA function returns the number of its arguments that are not empty.
    COUNTA(value, value…)
    value: Any value or a collectioncontaining any values.
    value…: Optionally include one or more additional values or collections.

  • How to count number of rows as well as the sum of a column in a procedure

    Hi, i need to count the number of rows a sql returns in a procedure.
    as well as i need to sum up a different column.
    i need the following output:
    count the number of rows output
    and sum the total column
    code:
    procedure samba_extraction (p_errmsg IN out varchar2
    ,p_errcode IN out NUMBER
    ,p_filename in varchar2
    ,p_start_date varchar2
    ,p_end_date varchar2)
    is
    file_handle utl_file.file_type; -- file handle of os flat file
    -- cursor to select the c_samba_resources
    cursor c_samba is
    select
    lpad(h.contract_number,15,'0') contract_number
    ,h.short_description description
    ,h.attribute_category context_value
    ,h.attribute7 samba
    ,h.attribute8 samba_number
    ,h.start_date start_date
    ,h.end_date end_date
    ,h.sts_code active_inactive
    ,l.price_negotiated price
    ,l.tax_amount tax
    ,LTRIM(to_char((l.price_negotiated + l.tax_amount),'00000000.00')) total
    from
    oks_auth_headers_v h
    ,oks_auth_lines_v l
    where h.id = l.chr_id
    and ((h.start_date <= (p_end_date))
    and (h.end_date >= (p_start_date)))
    and h.attribute7 = 'SAMBA'
    -- and h.sts_code = 'ACTIVE'
    and ((h.attribute_category = 'SUBSCRIPTION.DURATION')
    or (h.attribute_category = 'SUBSCRIPTION.VALUE')
    or (h.attribute_category ='SUBSCRIPTION.QUANTITY'));
    l_output varchar2(1000);
    l_counter varchar2(11);
    l_total varchar2(11);
    l_filename varchar2(30);
    begin
    if p_filename IS NOT NULL then
    -- l_batch_no := 'T';
    l_filename := p_filename || '.txt';
    -- open file to write into and obtain its file_handle.
    file_handle := utl_file.fopen('/usr/tmp',l_filename,'W');
    fnd_file.put_line(fnd_file.log,'The '|| l_filename||' file you have requested has been placed in the usr/tmp directory');
    for l_info in c_samba
    loop
    -- l_output := null;
    l_output := l_info.samba_number||'+'||l_info.total||l_info.contract_number;
    utl_file.put_line(file_handle,l_output);
    fnd_file.put_line(fnd_file.output, l_output);
    dbms_output.put_line(l_output);
    end loop;
    else
    p_errmsg := ('Please enter a filename for this file ');
    write_log('UPDATE : ' ||p_errmsg);
    end if;
    -- close the file.
    utl_file.fclose(file_handle);
    exception
    when no_data_found then
    dbms_output.put_line('no_data_found');
    utl_file.fclose(file_handle);
    when utl_file.invalid_path then
    dbms_output.put_line('UTL_FILE.INVALID_PATH');
    utl_file.fclose(file_handle);
    when utl_file.read_error then
    dbms_output.put_line(' UTL_FILE.READ_ERROR');
    utl_file.fclose(file_handle);
    when utl_file.write_error then
    dbms_output.put_line('UTL_FILE.WRITE_ERROR');
    utl_file.fclose(file_handle);
    when others then
    dbms_output.put_line('other stuff');
    utl_file.fclose(file_handle);
    end samba_extraction;
    end xx_samba;

    Hi,
    Initialise one variable TOT_ROWS to 0.
    Then in the for loop
    tot_rows := tot_rows + +1 ;
    so after for loop the value in the tot_rows will be the total records..
    If u want it to get this value in the calling procedure of this , just declare tot_rows parameter as out parameter.
    For sum of a column:
    Initialise a variable sum_col to 0.
    In the for loop
    sum_col := sum_col+I_info.column_name
    aprameter if u wish return this value as out..
    I think this wil give u the o/p..
    cheers,
    Sivarama

  • How to count number of rows in a cursor???

    I have a cursor and i want to check number of row fetched...But not through rowcount... bcoz it will give after fetching all the rows..
    I want to get count as soon as i open the cursor..plz let me know

    David_Aldridge wrote:
    hmmm ... you'd have to wrap the query in an inline view and apply the count(*) over() in the main query I guess.Still will not cover all cases:
    Session 1:
    update emp set deptno = deptno where deptno = 20
    5 rows updated.
    SQL> Session 2:
    select  ename,
            count(*) over()
      from  emp
      for update
      skip locked
    ENAME      COUNT(*)OVER()
    ALLEN                  14
    WARD                   14
    MARTIN                 14
    BLAKE                  14
    CLARK                  14
    KING                   14
    TURNER                 14
    JAMES                  14
    MILLER                 14
    9 rows selected.Now try to wrap the above query in an inline view :).
    SY.

Maybe you are looking for

  • Getting error while posting invoice in T-code F-02

    Hello, When i try to post invoice in T-code F-02 gives me the error message"There is no item category assigned to account bank a/c/company" Can any one suggest me why this is error came up and how to resolve this. Thanks, Lavi

  • Help with returning query from loadURL()

    I finally came across loadURL() and figured out that I can use it to invoke my ColdFusion components without page reloading--very handy! Now, I need to figure out how to do this to return values from my components. Has anyone done this and have an ex

  • Creating new JSF2 pages from a running Servlet (3.0) or JSF2 page?

    I'm new to JEE6 web apps with JSF 2.x frontends (GlassFish 3), and I still wasn't able to find a solution for this dynamic JSF 2.x problem: *From inside a running JSF 2.x web app (Servlet 3.0), which possibilities (if any) do I have to dynamically ad

  • Woke up this morning and my ipad2 can no longer send emails

    This morning after working late & sending emails last night, i turned on my ipad to see what replies i had and it was slow in connecting to the server I received a few emails and typed a reply, but it would not send So I powered down the ipad, thinki

  • I NEED CLARIFICATION ON THIS CLAIM!!!!

    ====SOME .NET GUY WAS CLAIMING THE FOLLOWING IN A .NET BOOK. I NEED TO KNOW IF ANYONE HAS EXPERIENCED THE SAME============= "One attempt to solve the problem of creating software that will work on multiple platforms has been to use Sun Microsystems�