use the where by max data

User avatar
sal21
PlatinumLounger
Posts: 4576
Joined: 26 Apr 2010, 17:36

use the where by max data

Post by sal21 »

I have a table with 9 fileds.
One of this is a date named mydata
I need to extract a distinct all ROW by max date where mydata.
How to?

IDCLI COGNOME NOME IL
61 DE RUBERTIS GIOVANNI 19/12/2024
64 PINGO PONGO 05/12/2024
61 DE RUBERTIS GIOVANNI 30/11/2024
66 GRECO SAVERIO 13/12/2024
63 VENTURINI ALFIO 01/12/2024
60 ERCOLE MACISTE 30/11/2024
59 UNGARO SAVERIO 30/11/2024
62 FURIO COLOMBO 01/12/2024
65 DI TOMMASO MICHELE 06/12/2024
67 WERWR WERWER 18/12/2024

at the and of sql:

61 DE RUBERTIS GIOVANNI 19/12/2024
64 PINGO PONGO 05/12/2024
66 GRECO SAVERIO 13/12/2024
63 VENTURINI ALFIO 01/12/2024
60 ERCOLE MACISTE 30/11/2024
59 UNGARO SAVERIO 30/11/2024
62 FURIO COLOMBO 01/12/2024
65 DI TOMMASO MICHELE 06/12/2024
67 WERWR WERWER 18/12/2024

for DE RUBERTIS GIOVANNI with date= 19/12/2024
Last edited by sal21 on 26 Dec 2024, 17:37, edited 1 time in total.

George Hepworth
Lounger
Posts: 47
Joined: 13 Jun 2024, 12:24

Re: use the where by max data

Post by George Hepworth »

If I understand the requirement correctly, you need:

SELECT IDCLI, COGNOME, NOME, Max(IL) As LastIL
FROM YourTableNameGoesHere
GROUP BY IDCLI, COGNOME, NOME