I have Three TablesTable 1 = SchoolName rollno Result ClassCaptainStudent1 001 PASS NULL Student2 002 PASS NULLStudent3 003 PASS NULL Student4 004 PASS NULLStudent5 005 FAIL NULLClass1 006 PASS 003 Class2 007 FAIL 004A student may or may not be a apart of class and the relationshsip is defined in a different table. A studet can be a part of multiple classes as given below:Table 2 = StudentClassgroup_roll stud_roll006 001006 002006 005007 003007 004006 002Relation is defined as School.ClassCaptain = School.rollnoStudentClass.group_roll = School.rollnoStudentClass.stud_roll = School.rollnoTable 3 = BestStudentroll_no best_stud001 NULL002 NULL003 NULL004 NULL005 NULL006 001007 002 BestStudent.roll_no = School.rollnoBestStudent.best_stud = School.rollnoI want to find the following :Class_Name/Class_Result/Student_Name/Student_Result/ClassCaptain_Name/ClassCaptain_Result/BestStudent_Name/BestStudent_Result/StudentcountInClassClass1/PASS/student1/PASS/student3/PASS/Student1/PASS/4Class1/PASS/student2/PASS/student3/PASS/Student1/PASS/4Class1/PASS/student5/FAIL/student3/PASS/Student1/PASS/4Class2/FAIL/student3/PASS/student4/PASS/Student2/PASS/2Class2/FAIL/student4/PASS/student4/PASS/Student2/PASS/2Class1/FAIL/student2/PASS/student4/PASS/Student1/PASS/4Someoe please help me solve this puzzle. I'd really appreciate. When i Find one thing i tend to loose another.Here is what I could assemble (only the simple parts and need help with the complex one)select b.name [Class_Name], b.Result [Class_Result], c.name [Student_Name],c.Result [Student_Result], d.name [ClassCaptain_Name],d.Result [ClassCaptain_Result],d.name [BestStudent_Name],d.Result [BestStudent_Result],f.name [BestStudent_Name],f.Result [BestStudent_Result],count(*) as countitem [StudentCountInClass]from studentclass aINNER JOIN school b ON a.group_roll = b.contact_uuidINNER JOIN school c ON a.stud_roll = c.contact_uuidINNER JOIN school d ON b.classcaptain = d.contact_uuidINNER JOIN BestStudent e ON b.best_stud = e.contact_uuidINNER JOIN school f ON a.group_roll = b.contact_uuidGroup by b.name