SELECT t.id_type, brand, model, countMod FROM types t
LEFT JOIN (
SELECT p.id_type, brand, model, COUNT( model ) AS countMod
FROM products p
GROUP BY brand) p2
ON t.id_type = p2.id_type
WHERE t.id_type = "TCE"
ORDER BY brand
此查询工作正常,但我丢失了分组的模型,当然,在每个品牌下。
有没有办法列出和计算模型?
即brand1,model1,model2,model3,countMod=3——brand2,model1,model2,countMod=2。
任何帮助将不胜感激。谢谢