Course Content

Intermediate SQL

## Intermediate SQL

# More Complex Filtering

Previously, the school held a **competition** for students who took **Mathematics**, and some of them were rewarded. Now, the school wants to ensure that there are no students who **cheat** and take **more than one** exam, including the math exam.

Therefore, the school has asked us to **retrieve the last names** of those students who took **more than one** exam, one of which was `Mathematics`

.

Here is the query from our **previous assignment** that you can use as an example:

`SELECT student_surname, AVG(grade) as average_grade FROM student_grades GROUP BY student_surname HAVING COUNT(grade) > 1`

Here is a preview of the `student_grades`

table we are working with:

Task

Retrieve the **last names** of those students who received **more than one** `grade`

and one of the subjects they took was `Mathematics`

.

Note

Retrieve only the

`surname`

of these students. The answer should have only one column.

Task

Retrieve the **last names** of those students who received **more than one** `grade`

and one of the subjects they took was `Mathematics`

.

Note

Retrieve only the

`surname`

of these students. The answer should have only one column.

Everything was clear?

# More Complex Filtering

Previously, the school held a **competition** for students who took **Mathematics**, and some of them were rewarded. Now, the school wants to ensure that there are no students who **cheat** and take **more than one** exam, including the math exam.

Therefore, the school has asked us to **retrieve the last names** of those students who took **more than one** exam, one of which was `Mathematics`

.

Here is the query from our **previous assignment** that you can use as an example:

`SELECT student_surname, AVG(grade) as average_grade FROM student_grades GROUP BY student_surname HAVING COUNT(grade) > 1`

Here is a preview of the `student_grades`

table we are working with:

Task

Retrieve the **last names** of those students who received **more than one** `grade`

and one of the subjects they took was `Mathematics`

.

Note

Retrieve only the

`surname`

of these students. The answer should have only one column.

Task

**last names** of those students who received **more than one** `grade`

and one of the subjects they took was `Mathematics`

.

Note

Retrieve only the

`surname`

of these students. The answer should have only one column.

Everything was clear?

# More Complex Filtering

Previously, the school held a **competition** for students who took **Mathematics**, and some of them were rewarded. Now, the school wants to ensure that there are no students who **cheat** and take **more than one** exam, including the math exam.

Therefore, the school has asked us to **retrieve the last names** of those students who took **more than one** exam, one of which was `Mathematics`

.

Here is the query from our **previous assignment** that you can use as an example:

`SELECT student_surname, AVG(grade) as average_grade FROM student_grades GROUP BY student_surname HAVING COUNT(grade) > 1`

Here is a preview of the `student_grades`

table we are working with:

Task

**last names** of those students who received **more than one** `grade`

and one of the subjects they took was `Mathematics`

.

Note

Retrieve only the

`surname`

of these students. The answer should have only one column.

Task

**last names** of those students who received **more than one** `grade`

and one of the subjects they took was `Mathematics`

.

Note

Retrieve only the

`surname`

of these students. The answer should have only one column.

Everything was clear?

**competition** for students who took **Mathematics**, and some of them were rewarded. Now, the school wants to ensure that there are no students who **cheat** and take **more than one** exam, including the math exam.

**retrieve the last names** of those students who took **more than one** exam, one of which was `Mathematics`

.

Here is the query from our **previous assignment** that you can use as an example:

Here is a preview of the `student_grades`

table we are working with:

Task

**last names** of those students who received **more than one** `grade`

and one of the subjects they took was `Mathematics`

.

Note

Retrieve only the

`surname`

of these students. The answer should have only one column.