Query a column and a calculation of columns at the same time PostgreSQL
Posted
by pablo
on Stack Overflow
See other posts from Stack Overflow
or by pablo
Published on 2010-03-12T19:47:32Z
Indexed on
2010/03/12
23:07 UTC
Read the original article
Hit count: 247
Hi
I have two tables, Products and BundleProducts that have o2o relation with BaseProducts. A BundleProduct is a collection of Products using a m2m realtion to the Products table. Products has a price column and the price of a BundleProduct is calculated as the sum of the prices of its Products.
BaseProducts have columns like name and description so I can query it to get both Products and BundleProducts.
Is it possible to query and sort by price both for the price column of the Products and calculated price of the BundleProducts?
Thanks
© Stack Overflow or respective owner