0

We have a basic query, which get us; cat_id, parent_id, cat_name and the total entry_count which is then displayed in the form of a report... the current query is:

SELECT c.cat_id, c.parent_id, c.cat_name, count(t.entry_id) AS entry_count
FROM exp_categories c
JOIN exp_category_posts p ON p.cat_id=c.cat_id
LEFT JOIN exp_channel_titles t ON p.entry_id=t.entry_id AND  t.channel_id IN (2,6,7,8,9,10)
WHERE c.group_id=1
GROUP BY c.cat_id

This works, however we also want to get the TOTAL view_count_one for all entries in a given category...

Any ideas how this would be expanded to achieve this?

1 Answer 1

2

You should be able to simply add:

SUM(t.view_count_one) as view_count

... to your SELECT statement.

1
  • Thanks Derek, @nathanpitman also suggested the same, which works a treat. I need to read up on my select statements :)
    – paulcripps
    Commented Sep 1, 2015 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.