Answer the question
In order to leave comments, you need to log in
Group eating?
Hello!
ID - class number (1-11), NAME - class name (first class - eleventh class, i.e. string) and COUNT - how many students are in the class. Let's say so.
select ID, NAME, COUNT(*) from class c
group by c.id, c.name
It outputs
1 first class 40
2 second class ....
And I need three lines
Elementary school
Middle school
Junior school
where sum is 1 -4, 5-9 and 10-11 respectively.
That is, case when .... having ... is needed here? What is more correct?
Answer the question
In order to leave comments, you need to log in
select case when id in (1,2,3,4) then 'Начальная школа'
when id in (5,6,7,8,9) then 'Средняя школа'
when id in (10,11) then 'Младшая школа'
end Class_type,
COUNT(*) from class c
group by Class_type
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question