【发布时间】:2017-02-22 21:24:39
【问题描述】:
我正在尝试混合两个查询 postgresql
select stock_quant.product_id as prod_id, product_product.name_template as name ,sum(stock_quant.qty) as qty_quant
from stock_quant
join product_product on stock_quant.product_id = product_product.id
join stock_location on stock_quant.location_id = stock_location.id
where stock_location.usage in ('internal','transit')
group by stock_quant.product_id, product_product.name_template
order by stock_quant.product_id
这个给我的产品总数量在表 stock_quant 中 ,第二个查询让我得到另一个表“stock_history”中的数量总和
select stock_history.product_id as prod_id,product_product.name_template as name , sum(stock_history.quantity) as qty_history
from stock_history
join product_product on stock_history.product_id = product_product.id
group by stock_history.product_id,name
order by stock_history.product_id
好吧,我想做的是只显示两个总和对于相同产品 ofc 相等的产品 thnx 我真的很感谢一些解释
【问题讨论】:
-
好吧,如果您能提供表的架构,那就太好了。
标签: postgresql odoo-8