I have Student and Course Table:
Student(Roll_no(primary), Name, Course_id(foreign))
Course(Course_no(primary), Course_name)
How will I retrieve:
a. The table with the details of Courses in which more than 2 students got admitted.
b. The Course table along with a count column.
What I tried for the first problem:
SELECT * FROM Course WHERE(SELECT COUNT(*) FROM Student GROUP BY Course_no WHERE COUNT(*) > 2);
I'm not sure what I did, but that didn't work. I am new to Database System .
Sample: Student Table
+---------+----------+----------+-----------+
| Roll_no | Name | Semester | Course_no |
+---------+----------+----------+-----------+
| 1 | a | 3 | 101 |
| 2 | b | 5 | 101 |
| 3 | c | 3 | 101 |
| 4 | c | 3 | 101 |
| 5 | d | 3 | 101 |
| 7 | b | 4 | 102 |
+---------+----------+----------+-----------+
Course Table
+-----------+-------------+
| Course_no | Course_name |
+-----------+-------------+
| 101 | BCA |
| 102 | BSC |
+-----------+-------------+
For the First Part I expect a table like:
+-----------+-------------+
| Course_no | Course_name |
+-----------+-------------+
| 101 | BCA |
+-----------+-------------+
For the Second part I expect a table like
+-----------+----------------------+
| Course_no | Course_name |Total |
+-----------+-------------+--------+
| 101 | BCA |5 |
| 102 | BSC |1 |
+-----------+-------------+--------+