The second part of your UNION
statement does not contain field member_category
. This violates basic principle of UNION
which is that number and order of columns in each statement should be same.
To resolve the issue, you need to add member_category
both in the list of retrieved columns and in the GROUP BY
clause.