When you sacrifice a blocking creature, it does not deal combat damage, but the attacking creature it is blocking is still considered "blocked" and won't deal combat damage to you unless it has trample. You essentially get to chose whether to have your creature deal damage or whether to sacrifice it. The relevant rules are as follows
510.2. all combat damage that's been assigned is dealt simultaneously. This turn-based action doesn't use the stack. No player has the chance to cast spells or activate abilities between the time combat damage is assigned and the time it's dealt.
509.1h An attacking creature with one or more creatures declared as blockers for it becomes a blocked creature; one with no creatures declared as blockers for it becomes an unblocked creature.
510.1c A blocked creature assigns its combat damage to the creatures blocking it. If no creatures are currently blocking it (if, for example, they were destroyed or removed from combat), it assigns no combat damage.
702.19c If an attacking creature with trample is blocked, but there are no creatures blocking it when damage is assigned, all its damage is assigned to the player or planeswalker it's attacking.
Exception 1: if the blocking creature has sufficient toughness, indestructible, regeneration, etc, it can both deal damage and be sacrificed but that is a result of it surviving combat, not of anything in how combat damage works.
Exception 2: if the blocking creature has first strike or double strike and the attacking creature does not, the blocking creature can both deal damage and be sacrificed for an effect by sacrificing it during the first strike combat damage step (after first strike damage has been dealt but before regular combat damage has been dealt).
Historic note: before 2010, combat damage went on the stack and you could both have a creature deal combat damage and sacrifice it for an ability.