Recap - Join
Fait partie de la section Les fondamentaux du Journey SQL de Coddy. Leçon 45 sur 72.
Défi
MoyenTables et colonnes disponibles :
<strong>orders</strong>:<strong>id</strong>,<strong>customer_id</strong><strong>products</strong>:<strong>id</strong>,<strong>unit_price</strong>,<strong>units_in_stock</strong><strong>order_items</strong>:<strong>id</strong>,<strong>order_id</strong>,<strong>product_id</strong>,<strong>quantity</strong>
Trouvez les identifiants clients des clients qui ont commandé des produits avec un prix unitaire inférieur à 10, et listez la quantité totale de ces produits bon marché commandés par chaque client.
Renvoyez les colonnes suivantes :
- customer_id
- total_quantity (la somme des quantités de produits avec un prix unitaire < 10 pour chaque client)
Essayez vous-même
-- Listez la colonne de regroupement et la valeur agrégée que la tâche demande
SELECT ____
FROM orders
-- Chaque jointure nécessite une condition faisant correspondre une colonne id à la colonne qui pointe vers elle
INNER JOIN order_items ON ____
INNER JOIN products ON ____
-- Ensuite, ne gardez que les lignes qui satisfont le seuil décrit par la tâche
WHERE ____
GROUP BY orders.customer_id;Toutes les leçons de Les fondamentaux
4More Keywords
The IN keywordThe BETWEEN keywordThe LIKE keywordThe AS keywordRecap - Cellphone Models2Conditions
Conditions BasicsThe AND keywordThe OR keywordThe NOT keywordMultiple Conditions CombinedParenthesisBooleans5Arithmetic Operations
Mathematical OperatorsMathematical ColumnsThe Modulo OperationThe ROUND() Function3Specific Return Format
Null valuesSort Results Part 1Sort Results Part 2Recap - Cyber Security FirmLimit number of recordsRecap - Vehicle Factory6Intro Challenges
Recap - Parliamentary ElectionRecap - Police Criminal ArrestRecap - Bar Beverage ContainerRecap - Engineer new columnsEntraînez-vous par vous-même : Playground SQL