I'm trying to get the sum of a column but its printing only the value started in the variable
That's what i have:
double sum = 0;
PreparedStatement st = con.prepareStatement("SELECT SUM(REPLACE(`preço`, 'R$ ', '' )) AS valor FROM `vendatemp`");
ResultSet rs = st.executeQuery();
if(rs != null) {
while(rs.next()) {
sum = rs.getDouble(1);
}
}
JOptionPane.showMessageDialog(null, "Valor total a pagar: " + sum);
I think the problem is around this "getDouble", but i can't find anything to replace