Arithmetic operations in Java with data from the database [closed]

-1

What is the best way to calculate values in java? I need to make a method that returns the sum of all input and output and subtraction. Example: Insert all entries in Double 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 subtTotal, which is the current balance more the balance of the day. If you have an example you will be welcome.

I thought and use a for loop, but I do not know how! Can someone help me please!

    
asked by anonymous 25.05.2017 / 22:09

1 answer

1

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

The syntax is as follows:

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

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

    
25.05.2017 / 22:36