The Queries in this page solved at the library database. It is a sample database generated by randomly records. You can download it from the link. You will see more than 500 examples in the future. You can filter from the search panel above by selecting sql statements. I hope you will like it

SQL Group By Having Examples

1-) List the class names and number of students which the number of students more than 30.

Solution 1)

Select sinif,count(*) as StudentCount 
from students 
group by sinif
having count(*) >= 30


ETİKETLER

Select - Group By - Having - Alias -
2-) Delete students who have read less than 5 books.

Solution 1)

Delete from students 
where studentId in (Select studentId from borrows 
                group by studentId 
				having count(*)<5)


ETİKETLER

Delete - Where - Group By - Having - Sub Query -
Library Database
Database