Answer the question
In order to leave comments, you need to log in
How to count the number of students per course?
There is a database of students and groups. Group number example: P3-1; 19IS1-1; P4-2; IF2-1D;
I need one SQL query to count them.
Here are the codes separately, but I don’t know how to combine them into one, but they require me to SELECT COUNT(*) as count1 From Students Where Group_Number Like '%1-%'
SELECT COUNT(*) as count2 From Students Where Group_Number Like ' %2-%'
SELECT COUNT(*) as count3 From Students Where Group_Number Like '%3-%'
SELECT COUNT(*) as count4 From Students Where Group_Number Like '%4-%'
Answer the question
In order to leave comments, you need to log in
Something like
SELECT COUNT(*) N, SUBSTRING(Номер_группы, PATINDEX('%[12345]%', Номер_группы), 1) Course
FROM Студенты
GROUP BY Course;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question