-- 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 */