SQLSELECT NUMBER, MONTH, COUNT(*), split_part(code, '-', 1) FROM tab GROUP BY MONTH, split_part(code, '-', 1)
SELECT sum(Number) AS sum, month, left(code, 2) AS codeFROM tab GROUP BY month, code;
SQLSELECT COUNT(*), MONTH, split_part(code, '-', 1) FROM tab GROUP BY MONTH, split_part(code, '-', 1)
CREATE VIEW count_code AS SELECT count(*), monthz, left(code, 2) AS code FROM tab GROUP BY monthz, code;
SELECT sum(count), monthz, code FROM count_code GROUP BY monthz, code;
SQLSELECT count(*) AS Всего_записей, MONTH, split_part(code, '-', 1) AS КодFROM Разные таблицы WHERE разные таблицы по ключевым полям связываютсяGROUP BY 2, split_part(code, '-', 1)
SQLCREATE VIEW count_code AS SELECT count(*), monthz, LEFT(code, 2) AS code FROM tab GROUP BY monthz, code; SELECT sum(count), monthz, code FROM count_code GROUP BY monthz, code;
SQLSELECT sum(cnt), monthz, code FROM (SELECT COUNT(*) AS cnt, monthz, LEFT(code, 2) AS code FROM tab GROUP BY monthz, code ) AS src;