sql query returns incorrect result
Posted
by
reza saberi
on Stack Overflow
See other posts from Stack Overflow
or by reza saberi
Published on 2012-07-01T14:54:49Z
Indexed on
2012/07/01
15:16 UTC
Read the original article
Hit count: 195
mysql
I have a mysql database that stores quotation documents with some products that are clearly defining the price of each product in them, and a table for contracts storing contract details as well as customer code and quotation code to which it belongs. I have the following query to see how much is the total price of the quotation to write it in the invoice:
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
© Stack Overflow or respective owner