SELECT eav.value AS 'unspsc',COUNT( e.sku)
FROM catalog_product_entity e
JOIN catalog_product_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE ea.attribute_code="unspsccode"
GROUP BY eav.value
solved How to use group by in this cquery?