In this tutorial we’ll not use group by but we will group records. In other words we’ll group records not using group by. We should have at least two tables.
List the student’s all data and count of the book they read.
(Select count(*) from borrows where students.studentId = borrows.studentId) as Count
We used, subquery by column in this example.
The solution with group by same example.
Select students.studentId,name,surname,class,gender,birthdate,point,count(*) as count
where students.studentId = borrows.studentId
group by students.studentId,name,surname,class,gender,birthdate,point
We must write all column names that was listed after the group by clause like the example.
We can’t use students.* after group by clause in sql.