Java arithmetic operations with database data

Asked

Viewed 47 times

-1

What is the best way to calculate values in java? I need to make a method that returns the sum of all inputs and output and subtraction. Example: Insert all Double entries in column X, and all Double output in column Y (get the total of each column), to get the balance of the day, which is Input subtracted by Output and find the subtTotal, which is the current balance plus the day balance. If you have any examples you are welcome.

I thought and use a looping for, but I don’t know how to do it! Can someone help me, please!

1 answer

1

You can get this information directly from the database using an sql command called Sum.

The syntax happens this way:

Select 
    Sum('NOME_COLUNA') as resultado  
    from 
    'NOME_TABELA';

Having this information, you can work with these values in Java, or even mount a more elaborate select, which already returns you the necessary information.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.