[Mysql] Date la plus grande
Bonjour à tous,
dans une table je dispose
id_to |
date_debut |
date_fin |
id_option Croissant1 |
montant_option |
8 |
01/04/2022 |
30/06/2022 |
10 |
760.00 |
30 |
01/04/2022 |
24/06/2022 |
10 |
1760.00 |
9 |
01/04/2022 |
30/06/2022 |
11 |
2160.00 |
31 |
01/04/2022 |
26/06/2022 |
11 |
22160.00 |
32 |
01/04/2022 |
30/06/2022 |
12 |
660.00 |
10 |
01/04/2022 |
30/06/2022 |
12 |
760.00 |
33 |
01/04/2022 |
30/07/2022 |
13 |
1100.00 |
11 |
01/04/2022 |
30/06/2022 |
13 |
1100.00 |
12 |
01/04/2022 |
30/06/2022 |
14 |
2200.00 |
34 |
01/04/2022 |
28/07/2022 |
14 |
200.00 |
13 |
01/04/2022 |
30/06/2022 |
15 |
540.00 |
35 |
01/04/2022 |
02/07/2022 |
15 |
40.00 |
36 |
01/04/2022 |
30/06/2022 |
16 |
1170.00 |
14 |
01/04/2022 |
30/06/2022 |
16 |
170.00 |
37 |
01/04/2022 |
30/07/2022 |
17 |
17.00 |
15 |
01/04/2022 |
30/06/2022 |
17 |
170.00 |
38 |
01/04/2022 |
30/07/2022 |
18 |
270.00 |
16 |
01/04/2022 |
30/06/2022 |
18 |
270.00 |
39 |
01/04/2022 |
30/06/2022 |
19 |
4320.00 |
17 |
01/04/2022 |
30/06/2022 |
19 |
4320.00 |
40 |
01/04/2022 |
30/06/2022 |
20 |
1300.00 |
18 |
01/04/2022 |
30/06/2022 |
20 |
1300.00 |
41 |
01/04/2022 |
28/06/2022 |
21 |
1330.00 |
19 |
01/04/2022 |
30/06/2022 |
21 |
330.00 |
20 |
01/04/2022 |
30/06/2022 |
22 |
220.00 |
42 |
01/04/2022 |
30/07/2022 |
22 |
22220.00 |
21 |
01/04/2022 |
30/06/2022 |
23 |
540.00 |
43 |
01/04/2022 |
30/07/2022 |
23 |
540.00 |
22 |
01/04/2022 |
30/06/2022 |
24 |
230.00 |
44 |
01/04/2022 |
30/07/2022 |
24 |
1230.00 |
23 |
01/04/2022 |
30/06/2022 |
25 |
270.00 |
45 |
01/04/2022 |
30/07/2022 |
25 |
2270.00 |
24 |
01/04/2022 |
30/06/2022 |
26 |
1300.00 |
46 |
01/04/2022 |
30/06/2022 |
26 |
1300.00 |
25 |
01/04/2022 |
30/06/2022 |
27 |
450.00 |
47 |
01/04/2022 |
30/07/2022 |
27 |
4150.00 |
26 |
01/04/2022 |
30/06/2022 |
28 |
650.00 |
48 |
01/04/2022 |
30/06/2022 |
28 |
650.00 |
27 |
01/04/2022 |
30/06/2022 |
29 |
810.00 |
49 |
01/04/2022 |
28/06/2022 |
29 |
8110.00 |
28 |
01/04/2022 |
30/06/2022 |
30 |
540.00 |
50 |
01/04/2022 |
30/07/2022 |
30 |
540.00 |
29 |
01/04/2022 |
30/06/2022 |
31 |
1100.00 |
51 |
01/04/2022 |
31/07/2022 |
31 |
5500.00 |
je voudrais ressortir toute les options avec leur montant mais où la date est la plus grande.
J'ai essayé ceci, mais il me ressort 2 lignes par article
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| SELECT
tgo.id_option,
tgo.nom_option,
tgto.montant_option,
max(`date_fin`)
FROM
tg_tarif_option tgto
RIGHT JOIN tg_option tgo on tgo.id_option = tgto.id_option
group BY
tgo.id_option,
tgo.nom_option,
tgto.montant_option |
Par rapport a mon tableau, si je prends id_option='15' je voudrais n'avoir que la ligne id_to=35
Comment devrais-je m'y prendre au niveau de ma requête SQL ?
merci d'avance pour vos conseils
guigui69