neethu payal
SSC Eights!
Points: 867
More actions
March 24, 2014 at 6:13 am
#286906
i have a temp table #student_details
which contains below values
student_id subject_id
1 111
3 111
4 111
5 111
3 121
4 121
i need to select the students which is common in both subjects,what should i do???
i am new to sql, can anyone help??
Koen Verbeeck
SSC Guru
Points: 259115
March 24, 2014 at 6:21 am
#1699500
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 questionMy blog at https://sqlkover.com.MCSE Business Intelligence - Microsoft Data Platform MVP
March 24, 2014 at 6:32 am
#1699505
thanks a lot..
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply