I have an issue similare to multiple agg functions, with the difference that I cover more than one table:
I want to aggregate two-fold over a set of tables (see schema at the bottom):
Current wrong result:
(The second column actually counts the items of the third column.)
АВТОМАТИЗИРОВАТЬ 2 HD,agt
АВТОМАТИЗИРОВАТЬ 2 HD,coordin
АВТОМАТИЗИРОВАТЬ 2 HD,coordin
АВТОМАТИЗИРОВАТЬ 5 circum,predic,HD,1-compl,--
АВТОМАТИЗИРОВАТЬ 2 predic,HD
АВТОМАТИЗИРОВАТЬ 3 predic,circum,HD
Desired result:
АВТОМАТИЗИРОВАТЬ 1 HD,agt
АВТОМАТИЗИРОВАТЬ 2 HD,coordin
АВТОМАТИЗИРОВАТЬ 1 circum,predic,HD,1-compl,--
АВТОМАТИЗИРОВАТЬ 1 predic,HD
АВТОМАТИЗИРОВАТЬ 1 predic,circum,HD
The first column is the verb.
The third column should specify the usage of the verb in the first column.
The second column should count how many times this specific usage occurs.
select vp.verb, count(), group_concat(label.name) relation
from vp, label, vp_terminal, terminal
where label.idlabel==terminal.label_id
and vp_terminal.vp_id==vp.idvp
and vp_terminal.terminal_id==terminal.idterminal
group by vp.verb, vp.idvp
order by verb, relation
Database Schema:

One verb (phrase) contains multiple sets of terminals (= words).
The actual words don’t appear in this result, only their grammatical relation to the verb (HD, agt, coordin, predic …).
A set of relations defines one usage of the verb phrase and is indicated by one row, with the frequency counted (yet wrongly).
Output of the current query (wrong):

I found the answer finally: