SELECT challenges.goal_type, challenges.goal_value, min(achievements.score)
FROM challenges INNER JOIN achievements
ON challenges.id = achievements.challenge_id
WHERE ((achievements.user_id = 1))
GROUP BY challenges.goal_type, challenges.goal_value;
The returned results are expected for the SQL query. The problem is,
achievements has more columns than just score. I want to return the
rest of the achievements columns that coincide with the score but
only base the results returned on the achievements score. basically,
I need to return this...
goal_type | goal_value | min | data |
-----------+------------+------------------+-------+
1 | 3 | 2108.62817033333 | some |
1 | 10 | 273.2031039 | extra |
1 | 5 | | data |
2 | 1 | 505403.234299 | from |
4 | 0.1 | | achie |
1 | 20 | 32441.5453999 | table |
3 | 10 | 124.2600446 | |
3 | 30 | 116.657539166667 | |
Returning the exact same rows from challenges and achievements, but
including additional columns from achievements as well.