Hi,
1. Retrieve data to InfoPath from SQL Database using ADO Adapter queries.
2. Process the data (do the required calculations like sum of Monthly Expense). (However retrieved data is in the form of XML so for processing these data we have to load data XML into InfoPath)
3. Place the final results in InfoPath.
4. Place this code in the form load ...