-
SELECT NOART, LIBELLE
FROM ARTICLES
WHERE STOCK<10;
Algèbre relationnelle :
R1=SELECTION(ARTICLES, STOCK<10)
R2=PROJECTION(R1, NOART, LIBELLE)
-
SELECT *
FROM ARTICLES
WHERE PRIXINVENT BETWEEN 100 AND 300;
AR :
R1=SELECTION(ARTICLES, PRIXINVENT>=100 et PRIXINVENT<=300)
R2=PROJECTION(R1, NOART, LIBELLE, STOCK, PRIXINVENT)
-
SELECT *
FROM FOURNISSEURS
WHERE ADRFOUR IS NULL;
AR :
R1=SELECTION(FOURNISSEURS, ADRFOUR est "non renseigné")
R2=PROJECTION(R1, NOFOUR, NOMFOUR, ADRFOUR, VILLEFOUR)
-
SELECT *
FROM FOURNISSEURS
WHERE NOMFOUR LIKE 'STE%';
AR :
R1=SELECTION(FOURNISSEURS, NOMFOUR comme "STE%")
R2=PROJECTION(R1, NOFOUR, NOMFOUR, ADRFOUR, VILLEFOUR)
-
SELECT NOMFOUR, ADRFOUR, VILLEFOUR
FROM FOURNISSEURS F
JOIN ACHETER A
ON F.NOFOUR=A.NOFOUR
WHERE DELAI>20;
AR :
R1=SELECTION(ACHETER, DELAI>20)
R2=JOINTURE(R1, FOURNISSEURS, NOFOUR)
R2=PROJECTION(R1, NOMFOUR, ADRFOUR, VILLEFOUR)
-
SELECT COUNT(*) AS NbArticles
FROM ARTICLES;
AR :
NbArticles=CALCULER(ARTICLES, Comptage())
-
SELECT SUM(STOCK*PRIXINVENT) AS ValeurStock
FROM ARTICLES;
AR :
ValeurStock=CALCULER(ARTICLES, Somme(STOCK*PRIXINVENT))
-
SELECT NOART, LIBELLE, STOCK
FROM ARTICLES
ORDER BY STOCK DESC;
AR :
R1=PROJECTION(ARTICLES, NOART, LIBELLE, STOCK)
R2=TRI(R1, STOCK décroissant)
-
SELECT A.NOART, LIBELLE, MAX(PRIXACHAT) AS PMAX,
MIN(PRIXACHAT) AS PMIN, AVG(PRIXACHAT) AS PMOY
FROM ACHETER A
JOIN ARTICLES B
ON A.NOART = B.NOART
GROUP BY A.NOART, LIBELLE;
AR :
R1=REGROUPER_ET_CALCULER(ACHETER, NOART, PAMAX : MAX(PRIXACHAT), PAMIN : MIN(PRIXACHAT), PAMOY : MOYENNE(PRIXACHAT))
R2=JOINTURE(R1, ARTICLES, NOART)
R3=PROJECTION(R2, NOART, LIBELLE, PAMAX, PAMIN, PAMOY)
-
SELECT A.NOFOUR, NOMFOUR, AVG(DELAI) AS DelaiMoyen
FROM ACHETER A
JOIN FOURNISSEURS F
ON A.NOFOUR = F.NOFOUR
GROUP BY A.NOFOUR, NOMFOUR
HAVING COUNT(*) >=2;
AR :
R1=REGROUPER_ET_CALCULER(ACHETER, NOFOUR, Nb : Comptage(), DelaiMoyen : MOYENNE(DELAI))
R2=SELECTION(R1, Nb>=2)
R3=JOINTURE(R2, FOURNISSEURS, NOFOUR)
R4=PROJECTION(R3, NOFOUR, NOMFOUR, DelaiMoyen)
-
SELECT a.noart, libelle, nomfour, minprix
FROM acheter a
JOIN
(select noart, min(prixachat) as minprix
FROM acheter
group by noart) PMIN
ON a.noart = PMIN.noart AND a.prixachat = PMIN.minprix
JOIN fournisseurs f
ON a.nofour = f.nofour
JOIN articles l
ON a.noart = l.noart;
AR :
R1=REGROUPER_ET_CALCULER(ACHETER, NOART, minprix : MIN(prixachat))
R2=JOINTURE(R1, ACHETER, R1.NOART=ACHETER.NOART et R1.minprix=ACHETER.prixachat)
R3=JOINTURE(R2, FOURNISSEURS, NOFOUR)
R4=JOINTURE(R3, ARTICLES, NOART)
R5=PROJECTION(R3, NOART, LIBELLE, NOMFOUR, minprix)
-
SELECT f.nofour, nomfour, adrfour, villefour
FROM fournisseurs f
LEFT JOIN acheter a
on f.nofour = a.nofour
WHERE a.noart IS NULL;
AR :
R1=PROJECTION(FOURNISSEURS, NOFOUR)
R2=PROJECTION(ACHETER, NOFOUR)
R3=DIFFERENCE(R1, R2)
R4=JOINTURE(R3, FOURNISSEURS, NOFOUR)
R5=PROJECTION(R4, NOFOUR, NOMFOUR, ADRFOUR, VILLEFOUR)
ou
R1=JOINTURE_GAUCHE(FOURNISSEURS, ACHETER, NOFOUR)
R2=SELECTION(R1, NOART est NULL)
R3=PROJECTION(R2, NOFOUR, NOMFOUR, ADRFOUR, VILLEFOUR)
-
SELECT nomfour, a.prixachat as prix_100,
b.prixachat as prix_106
FROM acheter a
join acheter b
using(nofour)
JOIN fournisseurs
using(nofour)
WHERE a.noart=100 AND b.noart=106;
AR :
R1=SELECTION(ACHETER, NOART=100)
R2=SELECTION(ACHETER, NOART=106)
R3=JOINTURE(R1, R2, NOFOUR)
R4=JOINTURE(R3, FOURNISSEURS, NOFOUR)
R5=PROJECTION(R4, NOMFOUR, R1.prixachat, R2.prixachat)
-
SELECT a.noart, libelle, nomfour, a.prixachat, a.delai
FROM acheter a
JOIN acheter b
ON a.noart = b.noart
JOIN fournisseurs f
ON a.nofour = f.nofour
JOIN articles l
ON a.noart = l.noart
WHERE a.nofour <> b.nofour
order by a.noart;
AR :
R1=ACHETER
R2=JOINTURE(R1, ACHETER, NOART)
R3=SELECTION(R2, R1.NOFOUR<>ACHETER.NOFOUR)
R4=JOINTURE(R3, FOURNISSEURS, R1.NOFOUR=FOURNISSEURS.NOFOUR)
R5=JOINTURE(R4, ARTICLES, R1.NOART=ACHETER.NOART)
R6=PROJECTION(R5, R1.NOART, LIBELLE, NOMFOUR, R1.PRIXACHAT, R1.DELAI )
-
SELECT nofour, nomfour, count(*) as nombre_produits
FROM fournisseurs
join acheter
using(nofour)
GROUP BY nofour, nomfour
HAVING count(*) = (SELECT MAX(nb_prod) FROM
(SELECT count(*) as nb_prod
FROM acheter
GROUP BY nofour) A);
AR :
R1=REGROUPER_ET_CALCULER(ACHETER, NOFOUR, Nb_prod : Comptage())
Max_prod=CALCULER(R1, MAX(Nb_prod))
R2=REGROUPER_ET_CALCULER(ACHETER, NOFOUR, Nombre_produits : Comptage())
R3=SELECTION(R2, Nombre_produits=Max_prod)
R4=JOINTURE(R3, FOURNISSEURS, NOFOUR)
R5=PROJECTION(R4, NOFOUR, NOMFOUR, Nombre_produits)