[英]SQL sub query in SQL Server
The first table is pre
and the second is tran
. 第一个表是
pre
,第二个表是tran
。 I want the S_SSN
from tran
where no
and Code
of transcript matches with Code
and no
in pre
我想
S_SSN
从tran
那里no
和Code
成绩单与匹配Code
,并no
在pre
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.