Professional Documents
Culture Documents
1*/
select * from client where ville='Fès' or
ville='Meknès';
/*2.2*/
select numcom, datec from commande where numcli=2;
/*2.3*/
select * from produit where libelle like '%t%';
/*2.4*/
select * from client where ville is not null;
/*2.5*/
select cl.numcli,ville, numcom
from client cl, commande cm
where cl.numcli=cm.numcli and datec='2016-1-2';
/*ou bien:*/
select client.numcli,ville, numcom
from client join commande on
client.numcli=commande.numcli
where datec='2016-1-2';
/*2.6*/
/*ou bien:*/
select distinct libelle
from produit pr natural join commande cm natural join
detailcom dc
where cm.numcli=2;
/*2.7*/
select cm1.numcom
from commande cm1, commande cm2
where cm1.datec=cm2.datec and cm2.numcom=2;
/*2.8*/
select * from produit order by prixu limit 1;
/*ou bien*/
select * from produit where prixu =(select min(prixu)
from produit);
/*2.9*/
select cm.numcom, cm.numcli, cl.nom, sum(prixu*qcom)
as montant_total
from detailcom dc, produit pr , commande cm , client
cl
where dc.numcom=cm.numcom and dc.npro=pr.npro and
cm.numcli=cl.numcli
group by cm.numcom;
/*ou bien:*/
select numcom, numcli, nom, sum(prixu*qcom) as
montant_total
from commande natural join produit natural join
detailcom natural join client
group by numcom;
/*2.10:*/
select npro, sum(qcom) from detailcom dc, commande cm
where dc.numcom=cm.numcom and datec>='2016-01-01' and
qcom>2 group by npro;
/*ou bien:*/
select npro, sum(qcom) from detailcom natural join
commande where datec>='2016-01-01' and qcom>2 group by
npro;
/*2.11*/
update detailcom set qcom=qcom+2
where numcom=1 and npro=1;
/*2.12*/
delete from client where numcli=1;