'Customer retention rate in snowflake

I have this formula for the customer retention rate but kinda stuck in translating it into a sql code in snowflake:

Customer Retention rate: number of customers who purchased in the past AND in the period of [last 30 days] / number of customers who have purchased in the past [not including last 30 days]



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source