There is such a request:
SELECT r.id_nomenclature, n.name AS "name_nomenclature", COUNT(n.name) OVER (PARTITION BY rg.id_rsd_group) AS "count_nomenclature", rg.id_rsd_group AS "id_group", r.id AS "id_expend" FROM rsd AS r LEFT JOIN rsd_group AS rg ON rg.id_rsd = r.id LEFT JOIN nomenclature AS n ON n.id = r.id_nomenclature GROUP BY r.id_nomenclature, n.name, n.id, rg.id_rsd_group, r.id ORDER BY rg.id_rsd_group DESC; Here is his conclusion:
I need to write in count_nomenclature the number of identical name_nomenclature being in the same id_group group. but this query counts the number of all name_nomenclature in the id_group group, despite the fact that COUNT (n.name) is written there.
it turns out that the written COUNT (n.name) is equivalent to COUNT (*), so it should not be.
DBMS postgree. How to fix?

GROUP BY r.id_nomenclature, n.name, n.id, rg.id_rsd_group, r.id) data for another group (GROUP BY n.name)? By the way, why does the grouping also by n.id? - Akina