Note : Roll up summary field can only be defined on the master object.
While your formula fields calculate values using fields within a single record, roll-up summary fields calculate values from a set of related records, such as those in a related list. You can create roll-up summary fields that automatically display a value on a master record based on the values of records in a detail record. These detail records must be directly related to the master through a master-detail relationship.
The Roll up Summary field is basically of 4 types:
As, per our previous sessions on salesforce, lets create roll up field on object Course because this is the Master object.
I want to calculate total income from a course:
Go to App Setup | Create | Objects and click on New field and Select Roll up summary field.
In Step 2, enter the field name and help text etc.
For step 3, you will see below screen,
In above image, at 1 we have to select the child object, at 2 we have to select the field on which it should calculate.
In our case, Fees paid field is of Formula type which works on currency.
And in section 3 you ca specify weather this roll up summary field include all record or any specific record which comes under the criteria you specified.
So, after creation of Roll up field on Master object final look is shown below: