I’m having trouble on a query right now to retrieve only the last value saved for each group of results.
I explain myself with a table. I have these values:
| date | analyses | result|
| ------ | --------- | ----- |
| date 8 |analysis A | 10 |
| date 7 |analysis A | 15 |
| date 6 |analysis C | 12 |
| date 5 |analysis A | 13 |
| date 4 |analysis B | 17 |
| date 3 |analysis A | 25 |
| date 2 |analysis B | 20 |
| date 1 |analysis C | 10 |
I retrieve in my query all the results obtained for 3 types of analyses and I display their creation date from the most recent to the oldest.
I would now like to improve my query if possible so that it only gives me the last values for each analysis.
The expected result is:
| date | analyses | result|
| ----- | -------- | ----- |
| date 8 |analysis A | 10 |
| date 6 |analysis C | 12 |
| date 4 |analysis B | 17 |
My request now looks like this:
SELECT
date,
analyses,
results
FROM
table_results,
table_analyses,
WHERE
analyse in ('analysis A','analysis B','analysis C')
ORDER BY date DESC
I tried to use GROUP BY on the attribute analyses but without success (error: is not a GROUP BY expression...).
If anyone has an idea thank you in advance,
Have a good day