Sélectionner des éléments de deux tableaux
Créez une requête effectuant une jointure entre deux tableaux et sélectionnant des éléments des deux pour créer la sortie.
Procédure
Résultats
La requête doit ressembler à ceci :
FROM order AS o
UNNEST o.items
JOIN customer AS c ON c.custid = o.custid
SELECT {
c.name,
c.rating,
o.orderno,
itemno
}
Elle retourne le résultat suivant :
[
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1001,
"itemno": 347
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1001,
"itemno": 193
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1002,
"itemno": 460
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1002,
"itemno": 680
},
{
"name": "B. Pitt",
"rating": null,
"orderno": 1003,
"itemno": 120
},
{
"name": "B. Pitt",
"rating": null,
"orderno": 1003,
"itemno": 460
},
{
"name": "J. Roberts",
"rating": 565,
"orderno": 1004,
"itemno": 680
},
{
"name": "J. Roberts",
"rating": 565,
"orderno": 1004,
"itemno": 195
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 460
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 347
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 780
},
{
"name": "T. Hanks",
"rating": 750,
"orderno": 1005,
"itemno": 375
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1006,
"itemno": 680
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1006,
"itemno": 120
},
{
"name": "R. Duvall",
"rating": 640,
"orderno": 1006,
"itemno": 460
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1007,
"itemno": 185
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1007,
"itemno": 680
},
{
"name": "T. Cruise",
"rating": 750,
"orderno": 1008,
"itemno": 460
}
]