You canclaim exemption under Section 54 which states that any Long Term Capital Gain, arising to an Individual or HUF, from the Sale of a Residential Property (whether Self-Occupied or on Rent) shall be exempt to the extent such capital gains is invested in the
Purchase of another Residential Property within 1 year before or 2 years after the due date of transfer of the Property sold and/or
Construction of Residential house Property within a period of 3 years from the date of transfer/sale of property
Provided that the new Residential House Property purchased or constructed is not transferred within a period of 3 years from the date of acquisition
If the new property is sold within a period of 3 years from the date of its acquisition, then, for the purpose of computing the capital gains on this transfer, the cost of acquisition of this house property shall be reduced by the amount of capital gain exempt under section 54 earlier. The capital gain arising from this transfer will always be a short term capital gain.
So in your case, you can compute the amount of capital gains and if you buy a house with all the conditions above fulfilled, there will be no tax liability at your end.
Hope this clarifies.