Counting records in resultset

I am doing SQL statements just fine but how can I count the records that would be returned? For example if I had this:
SELECT * FROM tablename WHERE num=2
I was trying this:
SELECT COUNT(*) FROM tablename WHERE num=2
I was using this:
ResultSet SQLResult = SQLStatement.executeQuery(Query);
But how can I get the number of records returned?

I now have:
ResultSet SQLResult = SQLStatement.executeQuery(QueryCount);
if (SQLResult.next()){
SQLResult.getInt(1)}
How can I dump the count into a variable called adCount?
I have never used this before, would I do
adCount=SQLResult.getInt(1)?

Similar Messages

  • Counting records in Visual Composer

    Hi folks,
    I do have question I cannot find a solution ( maybe due to christmas turkey paralysis )
    I am using VC to call a RFC function in ERP system 'RFC_READ_TABLE' to access data from table.
    The table I access is a customer table containing Delta- Data
    Actually the system RFC function returns all records ( normally between 1 and 10 records).
    On VC side I'd like to display only the number of records to inform if new data is available.
    How can I count records internally in VC?
    ( I do not like to bring in data directly into BI because the application I write will merge BI Query data with non BI data)
    I'D like to use standard RFC function to receive data, but first hand I'd like to decide by number of entries whether to use data or not.
    Any help is appreciated
    TIA

    Hi Prachi,
    that's it.
    I never used that functionality for plain counting records being returned by tables
    It woks perfect.
    The glory shiny points are yours.
    Joerg

  • How to count records from 2 tables and show in RDLC Report

    hi all,
    its being a one day searching for the solution but No Luck.
     I have two SQL tables tblstudetail and tblfeereceiptdetail.
    i just want to count records from both tables and show in RDLC report.
    I tried SQl Query Like This:
    select a.session, a.course,
    Count(CASE a.ADstatus WHEN 'OK' THEN 1 ELSE 0 END ) AS Admission,
    Count(CASE s .I_receiptstatus WHEN 'OK' THEN 1 ELSE 0 END) AS Feeprint
    from
    tblstudetail a
    FULL join
    tblfeereceiptdetail s on s.studentID = a.studentID
    where a.session = '2015' AND s.Fsession = '2015' AND a.adcat = 'Regular'
    GROUP BY a.session,a.course
    ORDER by a.course
    The result Show the Same Value in Both columns
    Session    Course      Admission       FeeDetail
    2015          B.A. I               275              275
    2015          B.A. II              307             307
    2015         B.A. III             255            255
    2015          B.Sc. I             110             110
    2015           B.Sc. II           105            105
    2015          B.Sc. III            64               64
    Actully I want to Count How many ADMISSION have been Taken(FROM tblstudetail) and How many FEE RECEIPT have been Print (From tblfeereceiptdetail).
    please guide me for this as soon as possible.
    thanks in advance...

    I am counting 'OK' in both the table columns I.e 'ADstatus' in tblstudetail and 'feereceiptstatus' in tblfeereceiptdetail
    please suggest me

  • Counting records in crosstab report

    I am very new to the reporting world so apologies if this seems so simple.
    I am trying to understand how count records that meet certain criteria and I am at a loss as to how to make it work (Crystal Reports 2008)
    I am setting up a cross tab report where I am want to count records that vwSubscription.status="Active" AND vwSubscription.isDues=True
    I think I should be creating a Formula Field that tests the status and dues record and when they both meet the correct criteria then have the Formula Field in the Summarized field of the Cross Tab Expert...
    make sense? please help

    Yes. You should create a formula like this
    IF vwSubscription.status="Active" AND vwSubscription.isDues=True THEN
    1
    And in Cross tab Create A Sum  of this field under Summary fields.
    If you want this value to be displayed based on some group, cross tab will be a good option, else you can create a sum of this field and place it in Report header to get the total.
    HTH,
    Jyothi

  • How to count records in a page which are in detail section

    Hi
    Is there a option to count records in detail section and so that based on that can apply a formula.

    Hi
    can i place the below two formulas in section experpt ?
    my report is like
    gh#1 
    details-----which contains transactions related to above group for a country
    group footer#1contains line '--
    if for india there are 3 records in the same page there can be 2 or 3 records in detail section. like that a page can contain more than one country. if number of records are more and coming in next page then the whole section should be moved to new page.
    that is my req. can u suggest accordingly.....
    i want to count the number of records in detais which will vary also how can i put formula when they are going to next page?

  • Mysql database, counting records

    Hi!
    I have to store measured data to MySQL database. During this process I would like to count a number of records in a database table. It is also necessary to filter records. I'm using the SQL statement as follows:
    SELECT COUNT (fieldname) AS cnt FROM table WHERE condition
    Because I haven't got any result I've created a small database "mysweetdb" and table "icecream" to test my VIs (see picture bellow).
    The VI is attached. The result of counting is a 2D array (DB Tools Fetch Recordset Data.VI output) with one element (one row and one column). This element contains no data.
    I usually don't give up easily so I've created a similar MS ACCESS database and counted data in it. I've got a correct answer: 3. So it might be possible that there is something wrong with MySQL driver. But I've created a small Delphi project and I've counted records in MySQL database and MS ACCESS database. Both results were correct.
    Can anyone explain where is the problem in communication between LabView and MySQL database?
    Versions: XAMPP for Windows 1.7.3, LabView Developer Suite 2010 SP1, MySQL 5.1 ODBC driver
    Thanks in advance for your suggestions.
    Attachments:
    Count records.vi ‏19 KB

    ContDivConsult,
    thank you for your answer. An updated version of my VI is attached. It uses two options: LabSQL library and DB Connectivity Toolkit. LabSQL gives correct results.
    Regards,
    Ljubo.
    Attachments:
    Count records.vi ‏25 KB

  • Error: The sort order specified for distinct count records is incorrect

    When processing a measure group with a distinct count measure in it, i get the following error:
    "The sort order specified for distinct count records is incorrect."
    I have no idea what this means - any ideas?

    I had the same problem and your fix worked.  In more detail, the problematic field was contract_no.  I added a named calculation to the table in the Data Source View with the formula CHECKSUM(contract_no).  Then I created the distinct count measure on that named calculation.  And, lo and behold, the errors disappeared! 
    Thank you to Frank.
     - CindyCindy P Hoskey

  • Can i count row from ResultSet ?

    I would like to count row from ResultSet for
    take it into my array object because i must know number of row before create array object.
    Example:
    ResultSet rset = stmt.executeQuery("select * from user ");
    /*i = amount of ResultSet*/
    User[] user = new User;
    int l=0;
    while (rset.next()){
    user[l] = new User();
    user.name = rset.getString(1);
    l++;

    Hi,
    As per my knowledge there is no method by which you can get the count of items in a resultset directly. You will have to loop through the reseltset and set a variable for count. In your specific case I would advise you to use a Vetor instead of an array so that you need not bother about the size.
    ResultSet rset = stmt.executeQuery("select * from user ");
    Vector user = new Vector();
    while (rset.next()){
    user.addElement(rset.getString(1));
    Now you will have a Vector that holds the user info. To retrieve the user info loop through the Vector.
    for (int i; i<user.size(); i++){
    userName = user.elementAt(i);
    Hope I was of some help.
    cheers!!!
    Nish

  • COUNTING RECORDS AND DETERMINING AVERAGES IN REPORT WRITER

    I HAVE 10 GROUPS. I WANT TO BE ABLE TO COUNT RECORDS AND DETERMINE THE AVERAGE DAYS FOR EACH GROUP. I GET DAYS BY SUBTRACTING THE RECEIVED DATE FROM THE RESULT DATE. I WANT TO DETERMINE THE AVERAGE DAYS AND THE NUMBER OF RECORDS IN THE TOP 10%, THE TOP 20%, THE TOP 30%, THE TOP 40%, THE TOP 50%, THE TOP 60%, THE TOP 70%, THE TOP 80%, THE TOP 90%, AND THE TOP 100%. HOW DO I CODE MY LOOP IN PLSQL TO DO THIS? CAN I DO THIS IN REPORT WRITER?

    I am not sure about the exact thing that you are requiring. but you can get the top 100 and top 20 or top 300 etc. by using the ROWNUM function in sql statement.
    thanks

  • Leaf Count Record

    After backing up my hard drive and booting from my freshly made eDrive, I ran TechTool Pro 6's "Volume Rebuild" and after that ran it showed me the results, as usual. There were a few green items but one red. The "Leaf Count Record" went from 1777 to 625. I tried to find out what a Leaf Count Record is by googling it but only count find things on the error associated with this.
    So my first question is: What is a Leaf Count Record?
    Secondly, is there any problem with my Leaf Count going down, and should i be worried about it?
    Note: i went ahead with the rebuild since all the information i could find on Leaf Count Record is mostly about the Leaf Count going up and not down.

    After backing up my hard drive and booting from my freshly made eDrive, I ran TechTool Pro 6's "Volume Rebuild" and after that ran it showed me the results, as usual. There were a few green items but one red. The "Leaf Count Record" went from 1777 to 625. I tried to find out what a Leaf Count Record is by googling it but only count find things on the error associated with this.
    So my first question is: What is a Leaf Count Record?
    Secondly, is there any problem with my Leaf Count going down, and should i be worried about it?
    Note: i went ahead with the rebuild since all the information i could find on Leaf Count Record is mostly about the Leaf Count going up and not down.

  • Invalid Leaf Count Record

    When I repaired my startup disk with Disk Utility, an invalid leaf count record error was reported. From looking at other posts, it appears that one of the recommended things to do for this is trying to repair the issue with Disk Utility. I tried this using Disk Utility 4.1. I replaced my directory with the rebuilt directory. Unfortunately, when I started back up from my install CD and ran Repair Disk, the invalid leaf count record error was reported again.
    Any advice would be much appreciated... maybe I did something wrong.
    Thanks

    First, I realized that I had the error message wrong. I should have wrote "Invalid Leaf Record Count" originally instead of "Invalid Leaf Count Record". I doubt this makes a difference, but just in case there it is.
    Secondly, I am running 10.3.9 and have been doing so for quite some time. My understanding based on this is that DiskWarrior 4.1 should work. I took your advice and tried running DiskWarrior again. As I did previously, I simply booted from DiskWarrior because the disk I am trying to fix is my startup disk. I rebuilt and replaced the directory with DiskWarrior 4.1 again. As a matter of fact, I ran it multiple times while I had it going. I even ran it under the scavenge mode.
    After doing this, I restarted the computer, ejected the DiskWarrior disc, and put in my install disc that came with my iMac. I booted from this CD and reran "Repair Disk" with Disk Utility. The error stills shows up. One thing to note is that my install disc came with 10.3.5 on it. Could this somehow cause a problem? My understanding is that you should always use an install disc for the major OS version you are running to run the "Repair Disk" function of Disk Utility. For example use an install disc for 10.3 if you are trying to repair a disk running 10.3.x or use an install disc for 10.4 if you are trying to repair a disk running 10.4.x.
    Prior to ever running DiskWarrior, I used the fsck command from single-user mode. Interestingly, the error did not show up here. I thought the "Repair Disk" function with Disk Utility was similar to this command, but maybe there is enough variation to cause the difference. Do you guys have any idea, which one I should trust?
    Let me know if any of this is incorrect. Any other suggestions regarding this error would be welcomed. I don't really understand what the error itself means. For now, I guess I will just leave it since I don't really know what else to do. Maybe in the future it will get worse and DiskWarrior will recognize it... I know that's asking for a problem!

  • Count records based on detail row containing a null date field

    i need to count the no of rows where a date field is null and print the result in each group footer. the formula isnull works well in details section  but not when I create a running total to count records where evaluate condition is based on a formula and when i test isnull(field) ?
    works in detail section:
    Global NumberVar numOpen;
    if (IsNull({db.DateField}))
    then numOpen := numOpen + 1;
    does not work in group footer?
    IsNull({db.DateField})

    Abhilash Kumar wrote:
    Well, what database are you reporting off and how did you insert a NULL value to the date column?
    In my case, I have worked with Oracle, Access, and now SQL.,
    and have used several different versions of Crysal (but never XI)
    I/we don't put anything into the date...  the field is simply empty and I use 
    IsNull({datefield})
    also for numbers (&currency)
    IsNull({numberfield})
    For text fields I now use
    IsNull({textfield}) or {textfield} not equal ""
    as SQL is a little funny about the empty text fields. Sometimes one works and sometimes the other so I use both.
    Debi

  • Knowing row-count withour iterating resultset

    Is there any way of knowing the
    row-count of a resultset without
    ever iterating the resultset?

    quite simply - NO.
    only you can have a boolean
    that can tell you whether or not
    your resultset had any rows.
    boolean isEmpty = true;
    while(rs.next())
         isEmpty = false;
    }//Check for isEmpty to know whether
    there was anything anywayz...

  • How to get count of a resultSet?

    Hi, everyone,
    Could anybody please tell me how to get the count of how many records in a resultSet? I went through the Java API for ResultSet, there is no such method in it.
    Thanks.

    Hi,
    I personnally simply use an INT variable which I increment during the loop, something like this :
    int nbRows = 0;
    while (rs.next()) {
    // do your rs.getXXX stuff here
    nbRows++;
    System.out.println("Total Nr of rows : "+nbRows);
    nbRows++. But there might be another better method for this ?
    You could also use an SQL Request like select count(*) or something, but this would be too much expensive for the performance (an additional statement, Result Set, SQL Query etc...).
    Hope this helps
    Alan

  • Comapring Records in ResultSet  ,Issue of Performance

    Hi,
    i got a Table on which I am calling select ,and getting the resultset as in which some of the rows will Have first column value as same ,but subsequent columns may have data or null Values.I want to club all the values for same First Column Value.I did it like that in java,but is it cab done in Oracle Procedures it self.
    Any analysis of this code and Database Loops ideas would be helpful.
    esultSetMetaData rsd = Rs2.getMetaData();
    int n = rsd.getColumnCount();
    Vector val = new Vector(n);
    Vector val2 = new Vector(n);
    System.out.println("No Of Columns--"+n);
    while(Rs2.next())
         if(Rs2.isFirst())
              for(int l=1;l<=n;l++)
              val.add(l-1,(Object)Rs2.getString(l));
         else
                   for(int j=1;j<=n;j++)
              val2.add(j-1,(Object)Rs2.getString(j));
                   if(val2.get(0).toString().equals(val.get(0).toString()))
                             System.out.println("same orderheaderid"+val2.get(0).toString());
                             i--;
                             for(int k=1;k<=n;k++)
                             if(val.get(k-1)==null)
                                  if(val2.get(k-1)!=null)
                                  val.set(k-1,val2.get(k-1));
                             val2.clear();
                             if(Rs2.isLast())
                                  for(int l=1;l<=n;l++)
                                       System.out.println(val.get(l-1));
                             else
                        else
                   {          System.out.println("different if"+val.get(0));
                             for(int f=1;f<=n;f++)
                                  System.out.println(f-1+"------"+val.get(f-1));
                        System.out.println("Count Value is--"+i);
                        val.clear();
                        val =(Vector)val2.clone();
                        if(Rs2.isLast())
                             for(int r=1;r<=n;r++)
                                  System.out.println(val2.get(r-1));
                        else
                             for(int s=1;s<n;s++)
                                  val.set(s-1,val2.get(s-1));
                        val2.clear();
                        val2 = (Vector)val.clone();
              }i++;
              //z++;
    Rs2.close();
    Thank u
    Vasu

    Double post:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=544516&tstart=0&trange=15
    http://forum.java.sun.com/thread.jsp?forum=48&thread=544517&tstart=0&trange=15
    Sounds like it breaks the rules for first normal form to me:
    http://databases.about.com/library/weekly/aa081901a.htm

Maybe you are looking for

  • Video Playback Dark

    Whenever I playback video using Quicktime, or in Final Cut Pro, just video playback period, videos are always very dark, and details hard to see. When I playback the exact same video (trailer from apple) then it plays back fine and with brightness an

  • IE9: AdobeEdge object doesn't support method loadComposition

    The edge animation does not load in IE9 just a blank page. Every other major browser works just fine. if I surround the script with a try catch like so: <!DOCTYPE html> <html> <head>   <meta http-equiv="Content-Type" content="text/html; charset=utf-8

  • FORMCALC (or JS) Default date today with user override questions

    I have a date field where if null, I want today to be inserted. If the user overrides the today date and saves the form, I want the user entered date to stay. What I have in FORMCALC is: if ($.isNull) then $.rawValue = num2date(date(), DateFmt(2)) en

  • VAT testing

    Can someone explain me the best way to test the VAT(Value Added Tax) functionality, to validate if it is working properly ..both for input and output VAT. Thank you

  • How to download sap solution manager

    Hi all, I'm studying SAP solution manager when I try to download solution manager components at site: https://websmp202.sap-ag.de/instguides with path: Download --> Installations and Upgrate --> My Company's Application Components" SAP SOLUTION MANAG