SELECT warehouse, product, SUM (quantity) qty FROM inventory GROUP BY GROUPING SETS( (warehouse,product), (warehouse), (product), () );