Hello,

Please, i need to know the JDBC code (applying servlet) to use with mySql to generate account balances from my customer_table having three columns(i.e. DEBIT, CREDIT,BALANCE) in the following format:


CR-------------------------DR----------------------BALANCE
30................................5..................................25
2..................................3..................................24


I can only use 'select sum....' code to get the sums of both DR and CR columns individually and then getting the difference of the two totals.

Please, anyone that has an idea should help me.

Thanks!!!

JNORA.

Recommended Answers

All 4 Replies

Your question is not clear at all. Is the table you posted your "customer_table" or the output that you require? If that is the desired output you will need to post the structure of the customer_table as well if you need help with the query. Also, post your current queries ithat are not working to your expectation.

HI EZZARAL,

Thanks for your prompt response. The 'customer_table' is my intended output table. But, the structure of the the original table is described below:

id int primary key not null,
debit int(50) not null,
credit int(50) not null,
balance int(50) not null

I am waiting for your reply, please. Thanks once again.

JNORA.

And which query are you having trouble with? Post what you currently have that is not working correctly.

weird requirements, clearly some homework assignment for learning SQL rather than a serious commercial project (or if it is, quit that job instantly).

The entire thing makes no sense at all. If you already have the ballance in the database (very bad, no real database would or should do that) there's nothing to calculate upon retrieval...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.