mysql query using jdbc
Posted
by S.PRATHIBA
on Stack Overflow
See other posts from Stack Overflow
or by S.PRATHIBA
Published on 2010-03-09T08:31:37Z
Indexed on
2010/03/09
8:36 UTC
Read the original article
Hit count: 702
Hi all,
I have the following table:
Service_ID feedback
31 1
32 1
33 1 1
I have the sample code to find the sum:
ResultSet res = st.executeQuery("SELECT Service_ID,SUM(consumer_feedback) FROM consumer5 group by Service_ID");
while (res.next())
{
int data=res.getInt(1);
System.out.println(data);
System.out.println("\n\n");
int c1 = res.getInt(2);
e[m]=res.getInt(2);
System.out.println("\n \n m is "+m+" e[m] is "+e[m]);
if(e[m]<0)
e[m]=0;
m++;
System.out.print(c1);
System.out.println("\t\t");
}
i have to get the output as
31 1
32 1
33 1
I am getting it.But for my project i have 34,35 also.I should get theoutput as
31 1
32 1
33 1
34 0
35 0
© Stack Overflow or respective owner