or download this
SELECT count(*) as count,category.category,nlevel(category.category) A
+S level,
subpath(category.category,0,nlevel(category.category)-1) as parent,
...
WHERE
data.category <@ category.category
GROUP BY category.category, category.head_title, category.cat_title, c
+ategory.subcat_title