diff --git a/plexpy/libraries.py b/plexpy/libraries.py index 1cc8cf55..50262905 100644 --- a/plexpy/libraries.py +++ b/plexpy/libraries.py @@ -836,7 +836,7 @@ class Libraries(object): 'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'WHERE section_id = ? ' \ 'GROUP BY session_history.rating_key ' \ - 'ORDER BY started DESC LIMIT ?' + 'ORDER BY MAX(started) DESC LIMIT ?' result = monitor_db.select(query, args=[section_id, limit]) else: result = [] diff --git a/plexpy/users.py b/plexpy/users.py index a41dd48e..7d6d6ae3 100644 --- a/plexpy/users.py +++ b/plexpy/users.py @@ -602,7 +602,7 @@ class Users(object): 'WHERE user_id = ? ' \ 'GROUP BY (CASE WHEN session_history.media_type = "track" THEN session_history.parent_rating_key ' \ ' ELSE session_history.rating_key END) ' \ - 'ORDER BY started DESC LIMIT ?' + 'ORDER BY MAX(started) DESC LIMIT ?' result = monitor_db.select(query, args=[user_id, limit]) else: result = []