If I understand the tax laws in Germany correctly, it is as follows:
Case 1: If I owned the apartment at least 10 years I don't have to pay taxes if I sell at a higher price than I bought it.
Case 2: If I lived in the apartment within three consecutive years before I sell it (not necessarily full years, but within the two calender years and the current year before selling the apartment) I also don't have to pay taxes.
Case 3: If the two situations above do not apply, I have to pay income tax on any gains.
Is my understanding correct? If yes, I have two follow-up questions:
In case 2: If I rented one room of the apartment and lived in the other room myself, does this still fulfill the requirements of case 2?
In case 3: Which costs can be deducted? The costs for the real estate agent when I bought the apartment? The costs when I sell it? The notary fees? The interest that I have to pay to my bank in the next years if the loan agreement does not allow to pay the entire home loan back at once?