The group by clause allows you to break down Heap queries even further by creating up to 4 groups within…