4. 列出政黨名單,當中最少有一名黨員在議會內。
Select party.name from
msp join party on
msp.party=party.code
Group by party.name
having count(party.name)>=1
6. 列出議會中每一政黨的黨員人數。
select party.name, count(msp.name)
from msp left outer join party
on msp.party = party.code
where party.name is not null
group by party.name
7. 列出每一政黨的議會中黨員人數,包括沒有黨員在議會中的政黨。
select party.name, count(msp.name)
from msp right outer join party
on msp.party = party.code
group by party.name
6.和 7.的区别在于外连接的主体不同,此处需要特别注意