SET FEEDBACK OFF
DROP TABLE T;

CREATE TABLE T (A INT, B VARCHAR(16), C INT);

INSERT INTO T VALUES (1, 'blue', 10);
INSERT INTO T VALUES (2, 'blue', 40);
INSERT INTO T VALUES (3, 'pink', 30);
INSERT INTO T VALUES (4, 'orange', 10);
INSERT INTO T VALUES (5, 'orange', 20);
INSERT INTO T VALUES (6, 'orange', 50);
INSERT INTO T VALUES (7, 'orange', 50);
INSERT INTO T VALUES (8, 'black', 50);
INSERT INTO T VALUES (9, 'black', 40);
INSERT INTO T VALUES (10, 'violet', 10); 
INSERT INTO T VALUES (11, 'violet', 20);
INSERT INTO T VALUES (12, 'violet', 10);

SET FEEDBACK ON

SELECT B, COUNT(*) FROM T GROUP BY B HAVING SUM(C)<=40;
SELECT B, COUNT(*) FROM T WHERE C>35 GROUP BY B HAVING COUNT(*)>=2;