Reputation: 73
I have a table that shows movie titles, production years and the number of scenes in each film and i want to make a query that shows the just the films with the least amount of scenes. so ive got this
SELECT title, production_year, SUM(scene_no)
FROM scene
GROUP BY title, production_year
ORDER BY SUM(scene_no);
but that just shows all the films in ascending order, i would like it to just show the films that appear at the top of this list.
can anyone help
Upvotes: 0
Views: 43
Reputation: 166
you can use limt , it just like top in sqlserver
SELECT title, production_year, SUM(scene_no)
FROM scene
GROUP BY title, production_year
ORDER BY SUM(scene_no)
LIMIT 1;
Upvotes: 1
Reputation: 324471
Add a LIMIT
clause, e.g.
ORDER BY sum(scene_no) ASC
LIMIT 10;
Upvotes: 0