• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC

 
Sindhu yandra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Query returning
select SUM(col1), SUM(col2),MeterId,opp_flow
from table1 group by MeterId,opp_flow

The rs is like this
sum(col1)sum(col2) meterIdOpp_flow
2500012000 ABCN
3500014000 ABCY
2500012000 DEFN
3500014000 DEFY

I want to display the data as
MeterIdsum(col1)sum(col2)
ABC25000-3500012000-14000
DEF 25000-35000 12000-14000
Means the data should be for a MeterId aggregating on Opposite Flow
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you are getting your results back in a ResultSet object, you can print them out in any order you want using the rs.getXXXX() methods. So for example, if you were just printing it on the console and MeterId is a String:
System.out.print(rs.getString("MeterId"));
And so on and so on...
What methods are you using to display the information? That will help better determine the best method for you to display the ResultSet.
 
Sindhu yandra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gregg Bolinger:
Well, if you are getting your results back in a ResultSet object, you can print them out in any order you want using the rs.getXXXX() methods. So for example, if you were just printing it on the console and MeterId is a String:
System.out.print(rs.getString("MeterId"));
And so on and so on...
What methods are you using to display the information? That will help better determine the best method for you to display the ResultSet.


I want to display the information summing on the opp_flow column. That is
for a meterid
if(opp_flow=="y")
variable1= total-sum(col1);
else if (opp_flow == "n")
variable1= total+sum(col1);
How do i develop the logic for summing up in the while(rs.next()) loop.
Hope i am clear!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic