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 Diaplaying a sum Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Diaplaying a sum" Watch "Diaplaying a sum" New topic

Diaplaying a sum

Frank Black

Joined: Mar 31, 2004
Posts: 10
I have a query on an excel spreadsheet that shows something like the following;
String sql = "select a.manager, sum(qty) "+
"from [db1$] a " +
" ,[db2$] b " +
"where a.dept = b.dept "
"and a.manager = b.manager " +
"group by a.manager ";

Statement s = conn.createStatement();
ResultSet rs = s.executeQuery(sql);
while (
System.out.print(" ");


To display the data I wanted to do the following;
Frank Black

Joined: Mar 31, 2004
Posts: 10
Sorry, hit enter to quickly!

Basically I want to know how to display my sum(qty) data?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32304

You have two choices:

1) rs.getInt(2);

2) String sql = "select a.manager, sum(qty) as total ";

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Frank Black

Joined: Mar 31, 2004
Posts: 10
Thanks Jeanne!
I agree. Here's the link:
subject: Diaplaying a sum
jQuery in Action, 3rd edition