An example of PostgreSQL function Assume that you have a table where Subscriptions are stored, example given you have bought a new Spotify subscription, for 3, 6 or 12 months. In this table , the data that are kept are : the creation date (created_at) last update timestamp (last_updated) start_date…