write a query to find the names of all students who have taken at least one comp.science course

by Prof. Jamir Hermann 3 min read

How to report all classes that have at least five students?

Each row of this table indicates the name of a student and the class in which they are enrolled. Write an SQL query to report all the classes that have at least five students. Return the result table in any order.

How to get the number of students in each class?

And then select the ones have more than 5 students. To get the student number in each class. We can use GROUP BY and COUNT, which is very popular used to statistic bases on some character in a table. Note: We use DISTINCT here since the student name may duplicated in a class as it is mentioned int he problem description.

How do I filter students with both Maths and Eng?

You can use the HAVING clause to filter only those who have both Maths and ENG : If you want aditional books, just play with the WHERE and HAVING , for 3 change them to this: Show activity on this post. This should solve your problem. Note that we are doing a self join on three copies of the student_books table:

How to find all students whose marks are greater than average?

Query in SQL is like a statement that performs a task. Here, we need to write a query to find all the students whose marks are greater than the average marks of students. We will first create a database named “ geeks ” then we will create a table “ Students ” in that database. Attention reader!