0% found this document useful (0 votes)
17 views

Exo SQL

The document contains examples of SQL queries grouped into four sections: 1) Aggregate functions, 2) Average, minimum, maximum and sum calculations, 3) Group by queries, 4) Subqueries. The queries demonstrate the use of COUNT, AVG, MIN, MAX, SUM and other aggregate functions as well as GROUP BY and subqueries.

Uploaded by

drfyhujim
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)
17 views

Exo SQL

The document contains examples of SQL queries grouped into four sections: 1) Aggregate functions, 2) Average, minimum, maximum and sum calculations, 3) Group by queries, 4) Subqueries. The queries demonstrate the use of COUNT, AVG, MIN, MAX, SUM and other aggregate functions as well as GROUP BY and subqueries.

Uploaded by

drfyhujim
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/ 4

agrégats → manquant : 3 – 3 | 4 - 4

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;

sous-requêtes → manquant : 2-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");

You might also like