SELECT id,name,sum(amount) as total_amount
from Contribution
GROUP by name
Now I need to add another column which uses the total amount by user and multiply it by 5 and then divide it by 100 and then add the results to the total amount.
Something like this
SELECT id,name,sum(amount) as total_amount,(sum(amount) * 5)/100 + (sum(amount)) as investment from Contribution
GROUP by name
I'm just curious and I might be missing it but where did the OP say that they were using SQL Server? They said the "have a sql query" but that doesn't mean SQL Server.