Professional Documents
Culture Documents
Exo SQL
Exo SQL
1
1
select count(*)
from employe
where fonction = "Représentant(e)";
2
select count(*)
from produit
where prixunit < 50;
3
select count(*)
from produit
where codecateg = 2
and unitesstock > 10;
4
select count(*)
from produit
where codecateg = 1
and nofour in (1, 18);
5
select count(distinct paysliv)
from commande;
6
select count(*)
from commande
where datecom = date("2016-03-28");
1
select avg(port)
from commande
where codecli = "Quick";
2
select min(port),
max(port)
from commande;
3
select sum(port)
from commande
where nomess = 1;
select sum(port)
from commande
where nomess = 2;
select sum(port)
from commande
where nomess = 3;
3
1
select fonction, count(*)
from employe
group by fonction;
2
select nomess,
avg(port)
from commande
group by nomess;
4
select codecateg,
avg(prixunit)
from produit
group by codecateg;
1
select nofour
from produit
group by nofour
having count(*) = 1;
2
select codecateg
from produit
group by codecateg;
having avg(prixunit) > 150;
3
select nofour
from produit
group by nofour
having count(distinct codecateg) = 1;
1
select nom, prenom
from employe
where noemp not in (
select noemp
from commande);
2
select count(*)
from produit
where nofour = (select nofour
from fournisseur
where societe = "Mayumis");
3
select count(*)
from commande
where noemp in (
select noemp
from employe
where rendcomptea = (
select noemp
from employe
where nom = "Emery"
and prenom = "Patrick"));
2
2
select societe
from fournisseur
where exists (
select *
from produit, detailcommande, commande
where produit.refprod = detailcommande.refprod
and detailcommande.nocom = commande.nocom
and paysliv = "france"
and nofour = fournisseur.nofour);
3
select societe
from fournisseur
where exists (
select *
from produit, categorie
where produit.codecateg = categorie.codecateg
and nofour = fournisseur.nofour
and nomcateg = "boissons");