Self-Serving bias is a cognitive process to maintain a favorable perseption of oneself. We tend to associate our good outcomes to our actions - but bad outcomes we attribute it to external factors. Eg. I got a 90% is maths because I studied hard - but I got a 20% in english because my teacher hates me.
Related to Fundemental Attribution Error
A self-serving bias is any cognitive or perceptual process that is distorted by the need to maintain and enhance self-esteem, or the tendency to perceive oneself in an overly favorable manner. It is the belief that individuals tend to ascribe success to their own abilities and efforts, but ascribe failure to external factors. When individuals reject the validity of negative feedback, focus on their strengths and achievements but overlook their faults and failures, or take more credit for their group's work than they give to other members, they are protecting their ego from threat and injury. These cognitive and perceptual tendencies perpetuate illusions and error, but they also serve the self's need for esteem. For example, a student who attributes earning a good grade on an exam to their own intelligence and preparation but attributes earning a poor grade to the teacher's poor teaching ability or unfair test questions might be exhibiting the self-serving bias.