File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes sql question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "sql question" Watch "sql question" New topic

sql question

michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
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.
Jyothi Lature
Ranch Hand

Joined: Oct 31, 2001
Posts: 60

This looks pretty simple!!!

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

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


I dont know if this is what you wanted.

Jyothi<br />Sun Certified Java Programmer<br />Brainbench Certified for Javascript
I agree. Here's the link:
subject: sql question
It's not a secret anymore!