能否在SQL内实现类似Excel Countifs函数功能例如 商家甲的A产品售卖200件,在表格中重复出现,则在统计列显示为2
连接查询+分组。
SELECT a.*, b.countif FROM `product` AS a JOIN ( SELECT NAME, merchant, count(*) AS countif FROM product GROUP BY NAME, merchant ) AS b ON b.NAME = a.NAME AND b.merchant = a.merchant;
2.1m questions
2.1m answers
63 comments
56.7k users