(select price from product_price where product_id=1)/(select price from comp_product_price where comp_product_id =1)

I'm holding the current price in the product price and the competitor product price at the comp_product_price. I would like to get the ratio of these. Above query gives the syntax error. How can i handle the issue? Thanks.

1 Answer 1


Use a JOIN:

select pp.price / cpp.price
from product_price pp 
  join comp_product_price cpp on pp.product_id = cpp.comp_product_id
where pp.product_id=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.