A Gentle Introduction to

SQL


Pick an engine:

Scottish ParliamentgoogleLe Parlement Écossais

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:googleThe 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: 129google... Nombre total des disques: 129
party
Code Name Leader
ConConservativeMcLetchie MSP, David
GreenGreen
LabLabourDewar MSP, Rt Hon Donald
... Total number of records: 9google... Nombre total des disques: 9

Selecting NULL valuesgoogleChoix des valeurs d'NULL

Dealing with NULL.googleTraiter NULL.

1a One MSP was kicked out of the Labour party and has no party. Find him. googleUn MSP a été donné un coup de pied hors du parti travailliste et n'a aucune partie. Trouvez-le.
Why we cannot use =

1b Obtain a list of all parties and leaders. E CrunchedObtenez d'une une liste toutes les parties et chefs.

1c Give the party and the leader for the parties which have leaders. googleDonnez la partie et le chef pour les parties qui ont des chefs.

1d Obtain a list of all parties which have at least one MSP. googleObtenez une liste de toutes les parties qui ont au moins un MSP.

Outer joins.googleExterne se joint.

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. googleObtenez une liste de tout le MSPs de nom, donnez le nom du MSP et le nom de la partie là où disponible. Soyez sûr qu'Canavan MSP, Dennis est dans la liste.

2b Obtain a list of parties together with the number of MSPs. googleObtenez une liste de parties ainsi que le nombre de MSPs.

2c A list of parties with the number of MSPs; include parties with no MSPs. googleUne liste de parties avec le nombre de MSPs; incluez les parties sans MSPs.

Self joins are the topic for the next tutorial.googleL'individu se joint sont la matière pour le prochain cours d'instruction.