I am doing an assignment for school, I hope someone can help.
I have to convert the following query which is using joins, into one that uses nested queries.
Original Query using Joins
---------------------------
select distinct s.sname, attend, sum(mark)
from stud s, result r, unit u
where s.sno = r.sno
and r.ucode = u.ucode
and u.uname = 'Practical Physical Endurance'
group by sname, attend
--------------------------------------
This is my attempt to solve it (with nested queries)
select distinct s.sname, s.attend, sum(r1.mark)
from stud s, result r1
where (s.sno, r1.mark) in
(select r2.sno, r2.mark
from result r2
where r2.ucode in
(select u.ucode
from unit u
where uname = 'Practical Physical Endurance'
)
)
group by s.sname, s.attend
I have to convert the following query which is using joins, into one that uses nested queries.
Original Query using Joins
---------------------------
select distinct s.sname, attend, sum(mark)
from stud s, result r, unit u
where s.sno = r.sno
and r.ucode = u.ucode
and u.uname = 'Practical Physical Endurance'
group by sname, attend
--------------------------------------
This is my attempt to solve it (with nested queries)
select distinct s.sname, s.attend, sum(r1.mark)
from stud s, result r1
where (s.sno, r1.mark) in
(select r2.sno, r2.mark
from result r2
where r2.ucode in
(select u.ucode
from unit u
where uname = 'Practical Physical Endurance'
)
)
group by s.sname, s.attend