T-SQL Tutorial

Inner Join SQL Tutorial


Inner Join Example:

SELECT s.student_id, s.name, SUM(b.price)
FROM students s INNER JOIN books b
ON s.student_id = b.student_id
GROUP BY b.price ;

Students table:

STUDENT_IDNAMEYEAR
1STUDENT_1I
2STUDENT_2II
3STUDENT_3III
4STUDENT_4IV

Books table:

BOOK_IDSTUDENT_IDPRICE
1140
2250
3370
41100
52120
6490
73200
82150

Inner Join Result:

STUDENT_IDNAMEPRICE
1STUDENT_1140
2STUDENT_2320
3STUDENT_3270
4STUDENT_490