SELECT SUBSTRING(Code_Spec, 0, CHARINDEX(‘-’,Group_number),1) AS Spec, COUNT(*) AS COUNTGROUP
FROM dbo.Students_Info
GROUP BY Code_Spec
SELECT SUBSTRING(nazv_spec, 0, CHARINDEX('-', Group_number), 1) AS Spec, COUNT(*) AS COUNTGROUP
FROM dbo.studenti_grupp
GROUP BY nazv_spec
SELECT SUBSTRING( nazv_spec, 0, CHARINDEX( '-', Group_number, 1)) AS Spec, COUNT(*) AS CountGroup
FROM studenti_grupp
GROUP BY SUBSTRING( nazv_spec, 0, CHARINDEX( '-', Group_number, 1))
ORDER BY 2 DESC