I try to use this query but did not grouping by major name
SELECT majors.name, count(students_industries.industry_id) as industri FROM majors
INNER JOIN groups ON majors.id=groups.major_id
INNER JOIN students ON groups.id=students.group_id
INNER JOIN students_industries ON students_industries.student_id= students.id WHERE students_industries.schedule_id = 2 GROUP by majors.name ,students_industries.industry_id;
if I use that query it will display 3 industrial data in the Informatics major because it counts from the number of students as well, while I hope that only 1 data will appear in informatics major
Here's a start on the DDL and sample data, but you're going to need to provide the other tables and data as well.
Create table #majors (id int , name varchar(2))
insert into #majors values
(1,'Informatics'),
(2,'Nursing')
Create table #students (id int , name varchar(2))
insert into #students values
(1,'Robert'),
(2,'Danny'),
(3,'Ratna')
Create table #industries (id int , name varchar(2))
insert into #industries values
(1,'Unilever'),
(2,'Amazons'),
(3,'Google')