SQL Join Questions


 Here are two sample tables:

Table: "Students"
```
| StudentID | Name     | Age | Grade |
|-----------|----------|-----|-------|
| 1         | Alice    | 18  | 12    |
| 2         | Bob      | 17  | 11    |
| 3         | Charlie  | 16  | 10    |
```

Table: "Courses"
```
| CourseID | CourseName  | StudentID |
|----------|-------------|-----------|
| 101      | Math        | 1         |
| 102      | Science     | 2         |
| 103      | History     | 1         |
| 104      | English     | 3         |
```

Now, here are five questions based on these tables:

1. Write an SQL query to retrieve the names of all students who are enrolled in the "Math" course.
2. Write an SQL query to find the course names taken by the student named "Bob".
3. Write an SQL query to display the names of all students along with the courses they are enrolled in, even if they are not enrolled in any course.
4. Write an SQL query to count the total number of students enrolled in each course.
5. Write an SQL query to list all students who are not enrolled in any course.



Contact us for software training, education or development










 

Post a Comment

0 Comments