Skip to content

Instantly share code, notes, and snippets.

@sebastien-gagneur
Last active October 20, 2021 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastien-gagneur/fdb1ff6f4c35a6795ee7704b17fc1d2e to your computer and use it in GitHub Desktop.
Save sebastien-gagneur/fdb1ff6f4c35a6795ee7704b17fc1d2e to your computer and use it in GitHub Desktop.
SQL code to introduce lesson 1 - Work with a table
void main()
{
// one call on Point()
Point A = Point.withParameters(2,1);
print(A.info());
// second call on Point()
Cercle C = Cercle.byDefault(A);
print(C.info());
Cercle D = Cercle.withParameters(3,A);
print(D.info());
//third call on Point()
ColorPoint Z = ColorPoint.withParameters("Green",A);
print(Z.info());
// fourth call on Point()
Pixel P = Pixel.withParameters("Blue", A);
print(P.info());
Photophore H = Photophore.byDefault();
print(H.info());
// five call on Point()
Photophore K = Photophore.withParameters(1,"R",P,Z,A);
print(K.info());
}
CREATE TABLE clients (
id INT primary key,
nom VARCHAR(255),
prenom VARCHAR(255),
ZIP INT
);
INSERT INTO clients (id, nom, prenom, ZIP) VALUES (1,"TOTO", "André", 63000);
INSERT INTO clients (id, nom, prenom, ZIP) VALUES (2,"TATA", "André", 99000);
INSERT INTO clients (id, nom, prenom, ZIP) VALUES (3,"fgdfgdf", "Henri", 98000);
INSERT INTO clients (id, nom, prenom, ZIP) VALUES (4,"fgdfgdf", "Henri", 75000);
INSERT INTO clients (id, nom, prenom, ZIP) VALUES (5,"fgdfgdf", "Xavier", 01000);
-- SELECT count(*) AS "Nombre d'invités pour ce soir" FROM clients;
-- Calculs
-- SELECT 1 + 1 ;
-- Sélection de colonnes
-- SELECT nom, prenom FROM clients;
-- restriction de lignes
-- SELECT * FROM clients WHERE id = 1;
-- Opérateur distinct, suppression des doublons
-- SELECT DISTINCT(prenom) FROM clients;
-- Expression complexe de restriction
-- SELECT * FROM clients WHERE ZIP < 75000 AND nom LIKE "f%";
-- Nombre de clients de ZIP = 75000
-- SELECT COUNT(*) AS "Nombre de client du ZIP = 75000" FROM clients WHERE ZIP = 75000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment