各製品の価格を明確に定義しているいくつかの製品を含む見積もり文書を格納するmysqlデータベースと、契約の詳細、およびそれが属する顧客コードと見積もりコードを格納する契約のテーブルがあります。請求書に記載する見積もりの合計金額を確認するには、次のクエリがあります。
select
sum(sqproducts.price * sqproducts.quantity) as 'total-price',
squotations.currency as 'currency'
from
sqproducts,
ccontracts,
squotations
where
sqproducts.contracted=1
AND squotations.code=sqproducts.quotation_code
AND sqproducts.quotation_code=ccontracts.squotation_code
AND sqproducts.quotation_code='QUOT/2012/1'
group by
currency