Выборка уникальных записей и подсчет их дубликатов

select count(*) as count_values,
attribute_value
from jos_vm_product_attribute
where attribute_name='Size'
group by attribute_value

Результат:

count_values 	attribute_value
7 	1
32 	10
9 	11
7 	13
7 	15
7 	3
8 	5
1 	5 1/2
32 	6
30 	6 1/2
39 	7
30 	7 1/2
32 	8
30 	8 1/2
39 	9
1242 	LARGE
27 	M/L
1242 	MEDIUM
68 	ONE SIZE
27 	S/M
1242 	SMALL
134 	XLARGE
21 	XSMALL

Выборка товаров без категорий в Virtuemart

SELECT * 
  FROM j25_virtuemart_products
  WHERE NOT EXISTS(
    SELECT * 
      FROM j25_virtuemart_product_categories 
      WHERE j25_virtuemart_product_categories.virtuemart_product_id=j25_virtuemart_products.virtuemart_product_id)