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
Solution 1)
Select sinif,count(*) as StudentCount
from students
group by sinif
ETİKETLER
Select - Group By - Aggragate -Solution 1)
Select gender,count(*) as StudentCount
from students
group by gender
ETİKETLER
Select - Group By - Aggragate - Alias -Solution 1)
Select sinif,gender,count(*) as StudentCount
from students
group by gender,sinif
ETİKETLER
Select - Group By - Aggragate - Alias -Solution 1)
Select sinif,gender,count(*) as StudentCount
from students
where gender = 'F'
group by gender,sinif
ETİKETLER
Select - Where - Group By - Aggragate - Alias -Solution 1)
Select sinif,count(*) as StudentCount
from students
group by sinif
having count(*) >= 30
ETİKETLER
Select - Group By - Having - Alias -Solution 1)
Select name,surname,count(*) BookCount
from students,borrows
where students.studentId = borrows.studentId
group by students.studentId,name,surname
Solution 2)
Select name,surname,count(*) BookCount
from students
join borrows on students.studentId = borrows.studentId
group by students.studentId,name,surname
ETİKETLER
Select - Join - Where - Group By - Aggragate - Alias - Çoklu Tablo -Solution 1)
Select name,surname,count(*) BookCount
from students
join borrows on students.studentId = borrows.studentId
group by students.studentId,name,surname
order by BookCount desc
Solution 2)
Select name,surname,count(*) BookCount
from students,borrows
where students.studentId = borrows.studentId
group by students.studentId,name,surname
order by BookCount desc
ETİKETLER
Select - Join - Where - Group By - Order By - Aggragate - Alias - Çoklu Tablo -Solution 1)
Select Year(takendate) as Year, datepart(qq,takendate) as Quarter,count(*) as Count
from borrows
group by Year(takendate),datepart(qq,takendate)
ETİKETLER
Select - Group By - SQL Functions -Solution 1)
Select Year(birthdate) as Year, datepart(qq,birthdate) as Quarter,count(*) as Count
from students
group by Year(birthdate),datepart(qq,birthdate)
ETİKETLER
Select - Group By - SQL Functions - Alias -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 -