Select Count(*) from Sample_table - how to get the count using JDBC?

Hi All,
It would be glad if anyone could help me with this. The problem is that I have to get the 'count' of records selected from a arbitrary table say, 'sample_table'. Is that possible to form the SQL in JDBC as
Select Count(*) from Sample_table
and get the value of the count? If yes, how?
Thanks in advance
Prabz

stmt = con.createStatement();
ResultSet recordcnt_rs = stmt.executeQuery("Select Count (*) as record_ctr From Sample_table");
recordcnt_rs.next();     
record_ctr = recordcnt_rs.getInt("record_ctr");
hope this helps.

Similar Messages

  • How to get the workcentres used in the routing out of 2 alternate routings

    Dear All,
    I would like to know how to get the workcentres used in the routing out of 2 alternate routings.
    I referred PLKO got the Task List Type (PLNTY), Group(PLNNR), Group Counter(PLNAL), Plant(werks).
    I passed this in to PLPO, The problem in PLPO is we don’t have the distinguishing field Group Counter(PLNAL), so I am getting all the ARBID including both alternates.
    How to get the ARBID with respect to Groupcounter 1 alone.
    If a get the ARBID , I can get the ARBPL from CRHD.

    HI,
    Use PLAS Table also.  you have to use PLKO> PLAS> PLPO.
    Pass PLNNR & PLNAL in PLAS and get PLNNR & PLNKN.
    Then pass these into PLPO.
    work centers from CRHD
    Regards,
    Krishna Mohan
    Edited by: Krishna Mohan N on Jan 31, 2008 12:28 PM

  • How to get the count of repeating elements in a xml doc.

    In many xml documents, in is common to have repeating child elements and what I would like to know is how do I determine exactly how many of these child elements exist in a particular document. There is probably a correct XPath string to determine this, but I cannot figure out what it is. Here is an example
    <a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>
    The above 'c' element is what varies in number from document to document and I need to know how to get the number of 'c' elements for the document, which would be 3 in the above case.

    create table test_xml(data xmltype)
    insert into test_xml values(
    xmltype('<a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>')
    select extract(data, '/a/b/c').getclobval() from test_xml
    select count(*) from test_xml
    where existsnode(data, '/a/b/c')=1
    good luck.

  • How to get the count of each minutes

    Oracle 10 DB
    Hi All
    I using this query to get the count of records fetched by the concurrent program per min,
    select count (distinct b.attribute2)
    from oe_order_headers_all a,oe_order_lines_all b
    where a.header_id=b.header_id
    and b.flow_status_code ='AWAIT_QUINTIQ_BOOK'
    and to_Char(b.last_update_date,'DD-MON-YYYY HH24:MI:SS') between '19-JAN-2011 02:00:01' AND
    '19-JAN-2011 02:00:02'
    This is used to get the count of records fetched at one mins
    How to find the count of last 10 mins ie 1 mins count 2.00 to 2.10
    Thanks & Regards
    Srikkanth.M

    Try this:
    SELECT TRUNC(b.last_update_date, 'mi') time_mins, COUNT(DISTINCT b.attribute2)
    FROM   oe_order_headers_all a,
           oe_order_lines_all b
    WHERE  a.header_id = b.header_id
    AND    b.flow_status_code = 'AWAIT_QUINTIQ_BOOK'
    AND    b.last_update_date >= to_date('19/01/2011 02:00:00', 'dd/mm/yyyy hh24:mi:ss')
    AND    b.last_update_date < to_date('19/01/2011 02:10:00', 'dd/mm/yyyy hh24:mi:ss')
    GROUP BY TRUNC(b.last_update_date, 'mi');I'm not sure why you're bothering with the join to the oe_order_headers_all table, since you're not referencing that in the where clause or the selected columns list. I think you could probably do away with it.
    I've changed your code to take the last_update_date and truncate it to the minute level, and added that as a column, so you can see which count goes with which minute. Obviously, this has to be in the group by.
    I've also changed your date comparisons so that you're actually comparing dates to dates, rather than strings to strings - why would you deliberately take information away from the optimizer? Oracle does not treat strings the same as dates, and forcing it to use strings rather than dates could lead you to have a vastly differing execution path, which will most likely be less performant.
    Not to mention, coding like that leads you to assume that you can compare dates in strings without any problems, and that is just not the case. '19-FEB-2011' is counted as being earlier than '19-JAN-2008', as strings sort alphabetically.

  • How to get the Count of a logic?

    Hi,
    Very new to CRM. I am trying to get the count of "activity start time" that are greater than current time stamp. Count(activity start time) work. I don't know how to add the time stamp condition to this. I can't add this condition as filter.
    Appreciate any responses.
    Thanks

    Raghu,
    Thanks for the help. It works to get the count.
    The problem is, i have some other filters set and can't combine this filter. Here is my scenario:
    get all activities on a contact that have greater than x $ amount as assets. I need to find the number of future appointments for that contact and start time of first pending future appointment. All has to be in one report.
    My columns are for example : contact name, activity start time, end time, subject, next pending appointment start time, total future appointments, some other related fields from contact
    So when I add the filter that you had given, it will not give me all activities. I am able to achieve all this in seperate reports and unnable to get it in single one.
    Thanks,
    GiGi

  • How to get the count of PO'S raised by a user

    Hi,
    I have a new requirement whr i am asked to get the count of number of PO'S raised by a particular user in report. Suppose the user raised 10 purchase orders .
    The requirement is when a user name is given it has to give count of 10.
    Where shud i include this,in rows or columns. Please suggest.
    Thanks&Regards,
    Praveen

    Hi Praveen,
    take a look in www.service.sap.com/bi, under old release, for release 2.x you will find an How to that detail how to count occurencies of a Char. Maybe you will find here the solution.
    Ciao.
    Riccardo.

  • How to get the count of all the entries in the DB?

    I want to know the way getting the count of the entries in a DB. Not using cursor to visit all entries and record the count.
    Message was edited by:
    user633842

    Hello,
    Yes, depending on the type of database you are using, the
    following statistics from DB->stat, look like what you want.
    For Hash databases:
    hash_ndata;
    The number of key/data pairs in the database. I
    For Btree databases:
    bt_ndata;
    For the Btree Access Method, the number of key/data pairs
    in the database.
    For the Recno Access Method, the number of records in
    the database.
    For Queue databases:
    qs_ndata;
    The number of records in the database.
    Additional details are at:
    http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_stat.html
    Thanks,
    Sandra

  • How to get the count monthly wise

    Hi All
    I have lot of order dispatched in a year 2010, how to get the moth wise total.
    For example jan 1000 orders ,feb 2500 orders.
    Thanks & Regards
    Srikkanth.M

    Pleiadian wrote:
    Maybe even
    b.schedule_ship_date between to_date('2010','YYYY') and to_date('2011','YYYY');)But this could return schedule ship dates that are 01-Jan-2011 00:00:00. I don't think this is wanted since it was not specified in the original requirement. I'm not even sure if to_date('2010','YYYY') returns 01. Feb.2010 in a few days (when we will have february).
    Just checking the docs....
    found it: http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#SQLRF51062
    from the docs:
    If you specify a date value without a time component, then the default time is midnight (00:00:00 or 12:00:00 for 24-hour and 12-hour clock time, respectively). If you specify a date value without a date, then the default date is the first day of the current month.Just to be on the safe side always give the complete format mask!
    b.schedule_ship_date >= to_date('01012010','DDMMYYYY')
    and b.schedule_ship_date < to_date('01012011','DDMMYYYY')Edited by: Sven W. on Jan 17, 2011 5:14 PM

  • How to get the count of distinct customer in matrix?

    Hi,
    I want to get the count of distinct customer in matrix at the time of validation event.
    Thanks Regards,

    Hi,
    Please close the thread.by marking the correct answer
    regards,
    Prasad

  • How to get the count of customers

    Hi all,
    We have a fact table, AR_F to which the dimensions Party_D and Fin_D are connected. Party-org_d is inturn connected to Party_d.
    party_org_D contains details of customers like Customer name and customer ID (Number)
    Fin_D contains ratings (Both -ve and +ve) of each customer.
    the rating range is as follows,
    good rating : >0
    OK Rating: Between 0 and -1.5
    Bad Rating: <-1.5
    Now i need to get the count of all customers falling in each range as separate measures.
    Kindly help me get a solution for this.
    Thank you.

    Hi,
    Try this....
    col 1
    case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end
    col 2
    case when (case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end)='Good' then count(customer_id)
    when (case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end)='Ok' then count(customer_id)
    when (case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end)='Bad' then count(customer_id)
    end
    hope helps........

  • HT4061 My ipad was stolen, i would like to ask how to get the IMEI using the serial number DL*******FJ1.

    my ipad 2 was stolen last january 7, 2013.  i want to know how to get the IMEI.  unfortunately i was not able to connect it to my pc even once.  but i can tract my ipad using my find my iphone in icloud. the serial no is DL*******FJ1.

    Do you have the original retail box the tablet came in? If so its where the barcode is located, ideally labeled as the IMEI.

  • How to get the count property from the oData response

    Hi,
    I have a fullscreen view in my Fiori app where we call a oData service through table.bindItems() inside the controller.
    The binding of items works fine but we have a situation when we need to display the total number of items (for e.g. 515) on the UI. We do not get this information from the VDM, so we plan to use the length property of the getList() method to determine the total number of items. But because of growing feature of the table it only reads 100 items at a time and the length property returns only 100. I have attached the listener attachRequestCompleted() for the model so that once the bindItems() request is complete i can get the length property. But my problem is that i want the total count.
    I saw in the debug that when this table.bindItems() gets called it makes a oData service call and in the response i can see that there is a count property available which has the total number of items (515 for my e.g.) but how do i read this count property from the response inside my controller (probably inside my attachRequestCompleted)?? I would really appreciate any help in this regard. Thanks.
    Kind Regards,
    Ashish
    Tags edited by: Michael Appleby

    HI Chandra,
    Thanks for your suggestions.
    But i think in my case we do not want to get the complete list. We still want to get only 100 items initially and then if the user would scroll down he/she would see more items. But we already need to know the total number of items for the purpose of showing a message to the user. For e.g. Total issues (515),  but the table would initially show only 100 and then another 100 after scroll. So setting the size litmit to max would not help.
    And to be able to use the $count you mentioned, we have to still make another oData service call which we do not want.
    But as i mentioned there is already a property named "__count" in the response of the bindItems() method call and i see that it has correct count but not sure how to retrieve it inside the controller. Thanks.
    Regards,
    Ashish

  • How to get the count of items(folders or documents) in a SharePoint document library and for a folder in any SharePoint document library?

    I need to get a count of documents and folders in a selected document library(the item for EventRecievers for event deleting) and the count of documents in a selected folder(the item for EventRecievers for event deleting) to determine whether the item(document
    library or folder) is empty or not, as I need to use this condition for one of my custom EventReceivers.
    Can you please suggest me the code to do the same?

    Hi.
    Try this:
    class Program
    static void Main(string[] args)
    using (SPSite site = new SPSite("http://z2012net"))
    using (SPWeb web = site.OpenWeb())
    SPList l = web.Lists["List001"];
    List<FolderInfo> res = new List<FolderInfo>();
    getListCount(l.RootFolder, ref res);
    private static void getListCount(SPFolder sPFolder, ref List<FolderInfo> res)
    SPQuery query = new SPQuery();
    query.Folder = sPFolder;
    res.Add(new FolderInfo() { ItemCount = sPFolder.ItemCount, Name = sPFolder.Name, Url = sPFolder.Url });
    SPListItemCollection items = sPFolder.ParentWeb.Lists[sPFolder.ParentListId].GetItems(query);
    foreach (SPListItem item in items)
    if (item.FileSystemObjectType == SPFileSystemObjectType.Folder)
    SPFolder f = sPFolder.ParentWeb.GetFolder(item.UniqueId);
    getListCount(f, ref res);
    class FolderInfo
    public string Url { get; set; }
    public string Name { get; set; }
    public int ItemCount { get; set; }
    Regards,
    Bubu
    http://zsvipullo.blogspot.it
    Please mark my answer if it helped you, I would greatly appreciate it.

  • How to get the count of the records

    Hi all,
    how can we get the record count after the read statement.Means if we write a read statement based on a condition,then how can we know that how many records get effected for this read statement

    You can use loop statement to read the records and write in some internal table and after the end of the loop, you can use describe command to find the number of records.
    For eg. DESCRIBE TABLE tablename LINES lines.
    Here the "Lines" field will give the total number of records present in the table "tablename"

  • How to get the count of the entries in the table view

    Hello experts,
             I have got a requirement where i need to display the total number of entries present in the table view, since the result comprises of several pages. This requirement is even applicable for the filter options in the table view i.e., if i use a filter it should count the total number of entries that satisfy the filter criteria.
    Thanks in advance,
    Vijayalakshmi

    hi,
    its simple,just place an input field in the layout and display the cpunt in that field.
    for that do as below,
    first in the layout of the page where you are giving tableview tab,in the next line give
    <b><htmlb:inputField id="Count"
                      value="<%=ln%>"
                      disabled = 'X'/></b>
    to display the count in that input field which is disabled.
    and if i am mot wrong in the Initialization event, you are writing select query right to populate internal table.
    after that write,
    <b>describe table it_mara lines ln.</b>
    and define this ln in page attributes as type i.
    do award points f it helps u,
    regards,
    Message was edited by:
            sowjanya s

Maybe you are looking for

  • Firefox Icon Replaced by Application icon after crash & repair, where can I get a copy compatible with Mac OSX 10.2.4?

    Recoveryng from a disk crash and Firefox icon in the genie bar vanished after running MAC Disk Utility and now has the "Application" (the A formed by a pen, pencil & ruler) icon instead. Will not launch. Need a version that will run Mac OS X 10.2.4.

  • Deferred Tax transfer problem

    1.- I have created a vendor down payment request with tax indicator f-48, then i enter G/L Account posting F-02, then I cleared in bank account the outgoing payment F-03. 2.-Then I make entering vendor invoice  FB60 and then I cleared the down paymen

  • How to display total amount field in PO layout

    Dear All, I have a query related to Purchase Order Printing. I copied the standard programme SAPFM06P as ZSAPFM06P. I didn't make any changes to standard program. I copied the standard layout MEDRUCK as ZMEDRUCK. I am able to display all the data of

  • Pavilion g6 1 d62nr failed printer install for priners

    HP Officejet 8600 Plus has stopped working. on my Pavilion g6-1d62nr.  Deleted the printer and tried to reinstall using wireless connection received error message "The printer installation failed" so I tried to set it up using a wired connection got

  • French characters in a JSP page

    I have an HTML page with a form that has a text field that can accept text from the user. This text can be multilanguage and when French charcters are in the text field, when the user submits the HTML form, my JSP that retrieves the text from the tex