shopkeeper table has following fields:

id (bigint),amount (numeric(19,2)),createddate (timestamp)

Let's say, I have the above table. I want to get the records for yesterday and generate a report by having the amount printed to cents.

One way of doing is to perform calculations in my java application and execute a simple query

Date previousDate ;// $1 calculate in application Date todayDate;// $2 calculate in application select amount where createddate between $1 and $2

and then loop through the records and convert amount to cents in my java application and generate the report

Another way is like performing calculations in sql query itself:

select cast(amount * 100 as int) as "Cents" from shopkeeper where createddate between date_trunc('day', now()) - interval '1 day' and date_trunc('day', now())

and then loop through the records and generate the report

In one way , all my processing is done in java application and a simple query is fired. In other case all the conversions and calculations is done in Sql query.

The above use case is just an example, in a real scenario a table can have many columns that require processing of the similar kind.

Can you please tell me which approach is better in terms of performance and other aspects and why?