DROP TABLE grouped_table;

CREATE TABLE grouped_table AS 
    SELECT 
        sector,
        CASE WHEn Sector LIKE 'Consumer%' THEN 'Consumer'ELSE 'other' END AS NewSector,
        COUNT(DISTINCT symbol) AS NrOfCompanies
    FROM SP500 
    GROUP BY sector;
    
SELECT * 
FROM grouped_table 
WHERE nrofcompanies > 50

    
