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 Distinct Examples

1-)

Solution 1)

Select count(distinct authorId) from students 
join borrows on students.studentId = borrows.studentId 
join books on books.bookId = borrows.bookId 
where students.name = 'Ida' and students.surname = 'Gray'


ETİKETLER

Select - Distinct - Join - Where - Multi Condition - Aggragate - Çoklu Tablo -
2-) Öğrenci isimlerini listeleyiniz. Aynı isimler bir kere listelensin

Solution 1)

Select distinct name from students


ETİKETLER

Select - Distinct -
3-) Sınıf isimlerini listeleyiniz. Aynı sınıf ismi bir kere listelensin?

Solution 1)

Select distinct class from students


ETİKETLER

Select - Distinct -
4-) Öğrencilerin sadece adını, soyadını listeletiniz. Aynı isim soyisimde olanlar bir kere listelensin

Solution 1)

Select distinct name, surname from students


ETİKETLER

Select - Distinct -
5-) 5 tane farklı öğrenci adı listeletiniz.

Solution 1)

Select distinct top 5  name from students


ETİKETLER

Select - Top - Distinct -
6-) 3 tane farklı kitap adı listeleyiniz.

Solution 1)

Select distinct top 3  name from books


ETİKETLER

Select - Top - Distinct -
Library Database
Database