• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sql question

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have this sql statement
SELECT count(*) as svcvol,sum(Amt) as svcsum,Status,Service,Compcode from SCTABLE where Status='00' GROUP BY Service

The problem is if there is no result matches it returns nothing. I want to display something even though there is nothing like displaying the compcode and the count is 0 and the sum is 0 and so on.
Is this possible. Thanks.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This looks pretty simple!!!

When you get the first row from ResultSet object by doing resultset_obj.next() and compare the value of svcvol == 0, then print the statement to be displayed.

For ex:
if (resultset_obj.next())
{
int count = rs.getInt(1);
if(count == 0)
System.out.println("NO RESULT FOUND................");

}

I dont know if this is what you wanted.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic