Think of the CGL limits as a set of buckets shown in the declarations. Some buckets cap a single event; the aggregates cap everything paid during the policy period.
General Aggregate Limit: the most the policy pays in total for Coverage C medical expenses, Coverage B damages, and Coverage A damages except those within the products-completed operations hazard.
Products-Completed Operations Aggregate Limit: a separate total cap for Coverage A damages within that hazard.
Each Occurrence Limit: the most paid for Coverage A damages plus Coverage C medical expenses arising from any one occurrence.
Personal and Advertising Injury Limit: the most paid under Coverage B for any one person or organization.
Damage To Premises Rented To You Limit: for damage to premises rented to the insured, such as by fire.
Medical Expense Limit: the most paid under Coverage C for any one person.
The each occurrence limit is shared by Coverages A and C. Example: a $1,000,000 each occurrence limit and a $5,000 medical expense limit. Coverage C pays an injured visitor $4,000, and the visitor then wins a $1,000,000 judgment for the same fall. The most the policy pays on the judgment is $996,000: subtract the $4,000 actually paid, not the full medical expense limit.
Defense costs are supplementary payments, so they do not reduce the limits. The right and duty to defend ends only when the applicable limit has been used up paying judgments or settlements under Coverages A or B, or medical expenses under Coverage C.