Quick Ref.

Scottish Parliament

The data includes all Members of the Scottish Parliament (MSPs) in 1999. Most MSPs belong to a political party. Some parties have a leader who is an MSP. There are two tables:

msp
Name Party Constituency
Adam MSP, BrianSNPNorth East Scotland
Aitken MSP, BillConGlasgow
Alexander MSP, Ms WendyLabPaisley North
... Total number of records: 129
party
Code Name Leader
ConConservativeMcLetchie MSP, David
GreenGreen
LabLabourDewar MSP, Rt Hon Donald
... Total number of records: 9

Selecting NULL values

Dealing with NULL.

1a. One MSP was kicked out of the Labour party and has no party. Find him.

Results
1b. Obtain a list of all parties and leaders.

Results
1c. Give the party and the leader for the parties which have leaders.

Results
1d. Obtain a list of all parties which have at least one MSP.

Results

Outer joins.

2a. Obtain a list of all MSPs by name, give the name of the MSP and the name of the party where available. Be sure that Canavan MSP, Dennis is in the list.
Use ORDER BY msp.name to sort your output by MSP.

Results
2b. Obtain a list of parties which have MSPs, include the number of MSPs.

Results
2c. A list of parties with the number of MSPs; include parties with no MSPs.

Results

Self joins are the topic for the next tutorial.


note

Sadly Donald Dewar died in 2000. An able and popular leader of the Labour Party in Scotland.