This is easy done with JavaScript:
Retrieve Function will be something like this:
var siteUrl = '/sites/MySiteCollection';
function retrieveListItems() {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('ListName');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><</Query></View>');
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
var group1Calculation=0;
var group2Calculation=0;
if(oListItem.get_item('groupName')=="Group1")
{
group1Calculation += parseInt(oListItem.get_item('monthly')) + parseint(oListItem.get_item('monthly'));
}
if(oListItem.get_item('groupName')=="Group2")
{
group2Calculation += parseInt(oListItem.get_item('monthly')) + parseint(oListItem.get_item('monthly'));
}
}
alert(group1Calculation.toString());
alert(group2Calculation.toString());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}