0
FLAG     MANAME                                   SUM(SUM_AMT)
-------- ---------------------------------------- ------------
Credit   Advance From Others                               999
Credit   Audit Expenses                                    567
Credit   Bank of Maharashtra                               100
Credit   CASH                                             2766
Credit   SBI                                               555
Credit   State Bank Of India                              3777
Credit   Sundry Creditors                                 1111
Credit   salaries payable                                  444
Debit    Advance From Others                             13332
Debit    Advance Travelling                               3000
Debit    Bank Charges                                        0
Debit    CASH                                             3333
Debit    General Expenses                                  555
Debit    Rates and Taxes                                   777
Debit    State Bank Of India                              1111
Debit    Sundry Creditors                                  200
Debit    salaries payable                                 2222

For my given query i got the above result set, but in that result set i want reduce duplicate name with single name, cal their amout (mean subtract Debit amount from Credit)

I think have to use some sorting technique for this, i use one technique iam getting data which r duplicate and calculate them, but not getting records which without duplicate.

Iam providing what i use technique

ResultSet rs=null;
 rs=st.executeQuery("select flag,maname,sum(sum_amt) from mob1 group by flag,maname");
 while(rs.next())
 {
	FLAG[p]=rs.getString(1);
	MANAME[p]=rs.getString(2);
	AMT[p]=rs.getInt(3);
	p++;
 }
 rs=null;
 int q=0;
 int s=0;
 int s1=0;
 for(int i=0;i<p-1;i++)
 {
	String x=FLAG[i];
	String y=MANAME[i];
	int z=AMT[i];
	for(int j=i+1;j<p;j++)
	 {
		String x1=FLAG[j];
		String y1=MANAME[j];
		int z1=AMT[j];
		if((y.equals(y1)) && !(x.equals(x1)))
		 {
			if(z>z1)
			 {
				NAME[q]=y;
				CRDR[q]=x;
				SUM[q]=z-z1;
				s=s+SUM[q];
				q++;
			 }
			 else
			 {
				NAME[q]=y;
				CRDR[q]=x1;
				SUM[q]=z1-z;
				s1=s1+SUM[q];
				q++;
			 }//else
			 
		 }//if
	 }//for(j
 }//for(i
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by lucky1981_iway
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.