从集合中查找用户定义的列而不进行分组

时间:2017-01-25 08:33:45

标签: mongodb python-2.7 mongodb-query pymongo aggregation-framework

如何从集合中找到用户定义的列,而不将其放在mongodb查询中的组中?

我想将以下SQL查询转换为mongo:

SELECT 
    brand_name,
    count(`qty/inventory`) AS totalstock,
    count(if(`qty/inventory`=0, `qty/inventory`, NULL)) as outofstock,
    count(if(`qty/inventory`!=0, `qty/inventory`, NULL)) as availablestock,
    DATE_ADD(stock_updated_at, INTERVAL 318 minute) as stock_updated_at 
FROM tbl_kunuzdatafeed_master 
GROUP BY brand_name 
ORDER BY stock_updated_at desc;

任何人都可以帮忙将其转换为mongo查询吗?

0 个答案:

没有答案