• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diaplaying a sum

 
Frank Black
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 (rs.next())
{
System.out.print(rs.getString("manager"));
System.out.print(" ");


}


To display the data I wanted to do the following;
 
Frank Black
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, hit enter to quickly!

Basically I want to know how to display my sum(qty) data?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank,
You have two choices:

1) rs.getInt(2);

2) String sql = "select a.manager, sum(qty) as total ";
rs.getInt("total");
 
Frank Black
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic