This is my database below I am coding with java and my workspace is eclipse
My question goes like this: I am trying to sum the column monthlypaid for each month for example in january except appartmentnum :1 every one paid
where the value 0 mean (didn't paid that month)
So in january 530+530+700+660+490+200
and on may 570+530+700+200
I should print it like this 1, january sum 2, febsum and I don't have a clue how to do it
I tried that but I think I am far away from solution
public static String select_Month_payment(String username) {
int i=1;
String answer="",ans="";
try {
PreparedStatement statement = connect.prepareStatement("select january,february,march,april,may,june,july,august,september,october,november,december from tenant where username= "+"'"+username+"'");
ResultSet result = statement.executeQuery();
while(result.next())
{
for (i=1;i<13;i++)
{
answer=result.getString(i);
if(!answer.matches("0") )
ans+= answer + " " ;
}
}
} catch (SQLException var2) {
var2.printStackTrace();
}
return ans;
}
