jeudi 14 janvier 2016

sqlite - select first n values with group by

I have following query:

SELECT folder_name, item_id, data, date, COUNT(item_id)
FROM images 
WHERE (1) 
GROUP BY 1, 2
ORDER BY MAX(date) DESC

This will return the most recent item (or items if more items have the same date) in a folder. I want to adjust this query to return the top 3 items of a folder instead. How would I do that?

I need to get the first 3 items of a folder + the count of items in each folder...

Any suggestions?

Aucun commentaire:

Enregistrer un commentaire