You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
778 B

-- Query 32
SELECT
tables.numtable,
SUM(comprend.qte * consommation.prixcons) AS prix
FROM tables
INNER JOIN facture ON facture.numtable = tables.numtable
INNER JOIN comprend ON comprend.numfacture = facture.numfacture
INNER JOIN consommation ON consommation.numcons = comprend.numcons
GROUP BY tables.numtable
HAVING prix = (
SELECT MAX(prix.prix)
FROM (
SELECT
SUM(comprend.qte * consommation.prixcons) AS prix
FROM tables
INNER JOIN facture ON facture.numtable = tables.numtable
INNER JOIN comprend ON comprend.numfacture = facture.numfacture
INNER JOIN consommation ON consommation.numcons = comprend.numcons
GROUP BY tables.numtable
) AS prix
);
/* == RESULT ==
"numtable","prix"
5,126.9
*/