2021. 4. 28. 15:48ㆍData science/Database
Practice exercises -Count, Distinct, LIMIT
Now, let us practice creating and running some LIMIT related queries.
Problem: Retrieve the name of the first 50 films distinctly.
-> SELECT DISTINCT Title FROM FilmLocations LIMIT 50;
Problem Retrieve first 10 film names distinctly released in 2015.
-> SELECT DISTINCT Titel FROM FilmLocations WHERE ReleaseYear = 2015 LIMIT 10;
Problem: Retrieve the next 3 film names distinctly after the first 5 films released in 2015.
-> SELECT DISTICT Title from FROM FilmLocations WHERE ReleaseYear = 2015 LIMIT 3 OFFSET 5;
(This time we want to retrieve a specific number of rows starting from a specific row in the table.)
Problem: Retrieve the number of distributors distinctly who distributed films acted by Clint Eastwood as 1st actor.
-> SELECT COUNT(DISTINCT Distributor) FROM FilmLocations WHERE Actor1 = "Clint EastWood";