From the following table,
userId passageId score 1 1 2 1 2 3 1 1 4 2 1 3 2 3 3 2 3 4
is it possible to extract the scores as shown below when the first two values of passageId are identical for each value of userId.
userId passageId score_1 score_2 1 1 2 4 2 3 3 4
DBFIDDLE
SELECT userId, passageId, min(score) as score_1, max(score) as score_2 FROM mytable GROUP BY userId, passageId HAVING COUNT(*)>=2;
2.1m questions
2.1m answers
60 comments
57.0k users