1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| SELECT v.id_user, v.id_element, v.id_categorie, tmp.derniere_date, MIN(v.valeur) AS valeur_mini
FROM valeur AS v
INNER JOIN (
SELECT id_user, id_element, id_catégorie, MAX(`date`) AS derniere_date
FROM valeur
WHERE valide = 1
GROUP BY id_user, id_element, id_categorie
) AS tmp
ON tmp.id_user = v.id_user
AND tmp.id_element = v.id_element
AND tmp.id_categorie = v.id_categorie
AND tmp.derniere_date = v.`date`
WHERE v.valide = 1
GROUP BY v.id_user, v.id_element, v.id_categorie, tmp.derniere_date
ORDER BY v.id_user, v.id_element, v.id_categorie, tmp.derniere_date |
Partager