SELECT student_id, cnt = COUNT(subject_id)
FROM #student_details
GROUP BY student_id
HAVING COUNT(subject_id) > 1;
Since this is most likely a homework assignment of some sorts, make sure you at least understand the solution given.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP