使用以下查询提取数据

时间:2017-04-12 15:54:20

标签: sql

我正在尝试从表中提取所需数据,但我需要添加另一个表

在完整的连接表之上,但它没有带来我需要的所需数据

分析。

SELECT pupil.pupil_id,english.pupil_id AS english_pupil_id,english.dis_id,english.element,english.points,maths.pupil_id
maths_pupil_id,maths.dis_id,maths.element,maths.points
FROM pupil,
(
SELECT P.Pupil_ID,P.dis_id, GR.element,GR.points
FROM [pupil] P,[Grade_Result] GR
WHERE P.Pupil_ID = GR.Pupil_ID
AND   GR.element IN('English','english','eglish')
AND   gr.points IN(9,8,7,6) 
)english
FULL JOIN   
(
SELECT P.Pupil_ID,P.dis_id, GR.element,GR.points
FROM [pupil] P,[Grade_Result] GR
WHERE P.Pupil_ID = GR.Pupil_ID
AND   GR.element IN('Maths', 'maths')
AND   gr.points IN(9,8,7,6)
)maths
ON  maths.Pupil_ID = english.Pupil_Id

0 个答案:

没有答案