aspose file tools*
The moose likes JDBC and the fly likes How to upper cast the average in db2 query? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to upper cast the average in db2 query?" Watch "How to upper cast the average in db2 query?" New topic
Author

How to upper cast the average in db2 query?

aypa genga
Greenhorn

Joined: Nov 26, 2008
Posts: 5
Hi all,

Below is the query :

i am getting SQL0802N Arithmetic overflow or other arithmetic exception occurred. SQLSTATE=22003 error in the below query for avg calculation.
The DUR_MILLISCNDS_CNT is integer.
Can Upper casting the average solve the error. How to upper Cast average.
Can you please help me in this.
------------------
try {
String sQuery="SELECT " +"Count(*) As DAILY_VOLUME, " +
"AVG( DUR_MILLISCNDS_CNT) AVERAGE_RESPONSE_TIME, " + ---- error occured----
"MIN ( DUR_MILLISCNDS_CNT) MINIMUM_RESPONSE_TIME, " +
"MAX ( DUR_MILLISCNDS_CNT) MAXIMUM_RESPONSE_TIME " +
"FROM " + dbName + ".TCAOP_MTRCS " +
"WHERE DATE( SESS_TS ) BETWEEN '" + fromDate + "' AND '" + toDate + "' " +
"AND RQST_DSCR ='" + componentList.get(i) +"' with ur";
// System.out.println("QRY === " + sQuery);
stmt=con.createStatement();
rs=stmt.executeQuery(sQuery);
if(rs.next()) {
String.valueOf(rs.getString("DAILY_VOLUME"));
volume = rs.getLong(1);
s.addCell(new Number(2,rowNo,volume,cInt));
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14273
    
  21

aypa, please check your private messages for an important administrative matter.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to upper cast the average in db2 query?