You have been using the ST_Union PostGIS function to make a polygon merge on a common attribute. This function can be used as an aggregate PostgreSQL function (such as SUM, COUNT, MIN, and MAX) on the layer's geometric field, using the common attribute in the GROUP BY clause.
Note that ST_Union can also be used as a non-aggregate function to perform the union of two geometries (which are the two input parameters).