Smallest Number Following Pattern Leetcode Problems Sql