I'm trying to create query with user_id parameter that would select one row per article_id where row with set user_id has priority. For example:
If user_id = 1, rows with id 2, 3, 4 should be selected.
If user_id = 2, rows with id 1, 3, 5 should be selected.
If user_id = 17, rows with id 1, 3, 4 should be selected.
Please consider pair (user_id, article_id) unique.
id user_id article_id
1 null 8
2 1 8
3 null 9
4 null 10
5 2 10