Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Counting number of rows returned by select

 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yall,
I am performing a select distinct sql statement in order to get a number of products from a table, I am not really interested in the product names themselves though, but am interested in how many of them there are, for example, if I have a table with rows like this:


And my sql is this:


I get returned the rows:
[B]Apple
Orange
Bannana[B]

But what I am interested in is the fact that there are three of them. Can I add something to the sql to have it return the number of rows returned (3) or do I have to iterate over the result set to find the number?
Thanks a bunch for any info,
Kim
 
nilesh Katakkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Select count(distinct FruitName) from PRODUCE
 
Kim Kantola
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic