Write an SQL query to report all the classes that have at least five students. Return the result table in any order.

A Guide to SQL
9th Edition
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Philip J. Pratt
Chapter2: Database Design Fundamentals
Section: Chapter Questions
Problem 11RQ
icon
Related questions
Question

I need the full code including (create table, insert...) and the output

Assuming you have a table in your database called 'Enrollment with the following schema:
Table: Enrollment
| Column Name | Type
| student
| class
| varchar |
| varchar |
+
(student, class) is the primary key column for this table.
Each row of this table indicates the name of a student and the class in which
they are enrolled.
The table contains the following data:
Input:
Enrollment table:
| student | class
| Math
| English
| Math
| Biology
| Math
| Computer I
| Math
| Math
| Math
| A
| B
| D
| E
| F
| G
| H
| I
Write an SQL query to report all the classes that have at least five students.
Return the result table in any order.
The result should be:
Output:
| class
| Math
Transcribed Image Text:Assuming you have a table in your database called 'Enrollment with the following schema: Table: Enrollment | Column Name | Type | student | class | varchar | | varchar | + (student, class) is the primary key column for this table. Each row of this table indicates the name of a student and the class in which they are enrolled. The table contains the following data: Input: Enrollment table: | student | class | Math | English | Math | Biology | Math | Computer I | Math | Math | Math | A | B | D | E | F | G | H | I Write an SQL query to report all the classes that have at least five students. Return the result table in any order. The result should be: Output: | class | Math
Expert Solution
Creating table:

To create a table named Enrollment, run following code:

CREATE TABLE Enrollment (
  student varchar PRIMARY KEY,
  class varchar NOT NULL
);
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Intermediate SQL concepts
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
A Guide to SQL
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr