The first table is pre and the second is tran. I want the S_SSN from tran where no and Code of transcript matches with Code and no in pre
1 Answer
Is this what you want?
;WITH Cte AS(
SELECT
t.Student_SSN,
cc = COUNT(t.Student_SSN)
FROM transcript t
INNER JOIN prereq p
ON t.C_no = p.P_no
AND t.D_Code = p.P_Code
WHERE
p.D_Code = 'INFS'
AND p.C_no = 614
GROUP BY t.Student_SSN
)
SELECT DISTINCT Student_SSN
FROM Cte
WHERE cc = (SELECT COUNT(*)
FROM prereq p
WHERE p.D_Code = 'INFS' AND p.C_no = 614)
5 Comments
user1989
This does not give me the appropriate results.
Felix Pamittan
Just add the appropriate filter.
user1989
The result I get from the Inner query should all be there, if all the requirements match. Then only I should take it.
user1989
Yes, I get the result, thanks. But is it possible to get the result without using count ?
user1989
Let us continue this discussion in chat.
811111111is your expected resultD_Code = INFSandC_no = 600also.