forked from Christian.Pape/gsd-questions
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
696 B
22 lines
696 B
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;
|