REGISTER or login:
I can't be sure that I understand what you want. It seems like you need a Query/400 query that gives results like this SQL query:
SELECT count(distinct FIELD1) ,
WHERE FIELD3 = 'something'
GROUP BY FIELD2
ORDER BY FIELD2
Please verify if that describes what you are asking for. If it does, then we can probably see how to use Query/400 to do it. I'm not sure why you'd want to use Query/400, though. It's clearly much easier just to use a SQL query.
This would get your part way there