0% found this document useful (0 votes)
4 views2 pages

R Esum e Complet Des Commandes SQL

This document provides a comprehensive overview of SQL commands specifically for data warehousing. It includes examples for various commands such as CREATE, SELECT, UPDATE, DELETE, and JOIN, along with their syntax. The document serves as a reference for executing common SQL operations in a data warehouse environment.

Uploaded by

emed40941
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

R Esum e Complet Des Commandes SQL

This document provides a comprehensive overview of SQL commands specifically for data warehousing. It includes examples for various commands such as CREATE, SELECT, UPDATE, DELETE, and JOIN, along with their syntax. The document serves as a reference for executing common SQL operations in a data warehouse environment.

Uploaded by

emed40941
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Résumé Complet des Commandes SQL

Commandes SQL — pour datawarehouse

Commande Exemple SQL


CREATE DATABASE CREATE DATABASE entreprise;
USE USE entreprise;
CREATE TABLE CREATE TABLE clients (id INT PRIMARY KEY, nom
VARCHAR(50), age INT);
INSERT INTO INSERT INTO clients (id, nom, age) VALUES (1,
’Ali’, 25);
SELECT SELECT nom, age FROM clients;
SELECT * SELECT * FROM clients;
WHERE SELECT * FROM clients WHERE age > 30;
AND / OR SELECT * FROM clients WHERE age > 30 AND pays =
’France’;
ORDER BY SELECT * FROM clients ORDER BY age DESC;
LIMIT SELECT * FROM clients LIMIT 5;
OFFSET SELECT * FROM clients LIMIT 5 OFFSET 10;
DISTINCT SELECT DISTINCT pays FROM clients;
IN SELECT * FROM clients WHERE pays IN (’France’,
’Canada’);
BETWEEN SELECT * FROM produits WHERE prix BETWEEN 10 AND
20;
LIKE SELECT * FROM clients WHERE nom LIKE ’A%’;
IS NULL SELECT * FROM commandes WHERE date livraison IS
NULL;
UPDATE UPDATE clients SET age = 26 WHERE nom = ’Ali’;
DELETE DELETE FROM clients WHERE nom = ’Ali’;

1
Commande Exemple SQL
DROP TABLE DROP TABLE clients;
GROUP BY SELECT age, COUNT(*) FROM clients GROUP BY age;
HAVING SELECT age, COUNT(*) FROM clients GROUP BY age
HAVING COUNT(*) > 2;
SUM() SELECT SUM(salaire) FROM employes;
AVG() SELECT AVG(note) FROM etudiants;
COUNT() SELECT COUNT(*) FROM commandes;
JOIN SELECT * FROM clients JOIN commandes ON
clients.id = commandes.client id;
LEFT JOIN SELECT * FROM clients LEFT JOIN commandes ON
clients.id = commandes.client id;
RIGHT JOIN SELECT * FROM clients RIGHT JOIN commandes ON
clients.id = commandes.client id;
FULL JOIN SELECT * FROM clients FULL OUTER JOIN commandes
ON clients.id = commandes.client id;
UNION SELECT nom FROM clients UNION SELECT nom FROM
fournisseurs;
CASE SELECT nom, CASE WHEN age >= 18 THEN ’Adulte’
ELSE ’Mineur’ END FROM clients;
EXISTS SELECT * FROM clients WHERE EXISTS (SELECT *
FROM commandes WHERE clients.id =
commandes.client id);
RANK() SELECT nom, RANK() OVER (ORDER BY score DESC)
FROM joueurs;
DENSE RANK() SELECT nom, DENSE RANK() OVER (ORDER BY score
DESC) FROM joueurs;
ROW NUMBER() SELECT nom, ROW NUMBER() OVER (ORDER BY score
DESC) FROM joueurs;
NTILE() SELECT nom, NTILE(4) OVER (ORDER BY score DESC)
FROM joueurs;
PARTITION BY SELECT nom, RANK() OVER (PARTITION BY equipe
ORDER BY score DESC) FROM joueurs;

You might also like