Attached is query to estract value based from IDCLI.
But i need to to extract also by the newest date in field IL.
in my case the date is 27/12/2024
plese with SQL for vb 6.0 and ado
SELECT ROW based the newest date
-
- PlatinumLounger
- Posts: 4576
- Joined: 26 Apr 2010, 17:36
SELECT ROW based the newest date
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 80088
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SELECT ROW based the newest date
Dim SQL As String
SQL = "SELECT IDCLI, COGNOME, NOME, DTNASC, NATOA, INDIRIZZO, PR, CAP, COM_RES, TELEFONO, CITTADIN, EMAIL FROM ANAGRAFICA WHERE IDCLI=61 AND IL=(SELECT Max(IL) FROM ANAGRAFICA WHERE IDCLI=61)"
SQL = "SELECT IDCLI, COGNOME, NOME, DTNASC, NATOA, INDIRIZZO, PR, CAP, COM_RES, TELEFONO, CITTADIN, EMAIL FROM ANAGRAFICA WHERE IDCLI=61 AND IL=(SELECT Max(IL) FROM ANAGRAFICA WHERE IDCLI=61)"
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4576
- Joined: 26 Apr 2010, 17:36
Re: SELECT ROW based the newest date
TKS.
Work.
But if i delete the IDCLI from the where clausole the SQL return only two recordset!
I need all row, always max(IL), im my case 9 rows
-
- Administrator
- Posts: 80088
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4576
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 80088
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SELECT ROW based the newest date
SQL = "SELECT IDCLI, COGNOME, NOME, DTNASC, NATOA, INDIRIZZO, PR, CAP, COM_RES, TELEFONO, CITTADIN, EMAIL FROM ANAGRAFICA WHERE IL=(SELECT Max(T.IL) FROM ANAGRAFICA AS T WHERE T.IDCLI=ANAGRAFICA.IDCLI)"
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4576
- Joined: 26 Apr 2010, 17:36
-
- PlatinumLounger
- Posts: 4576
- Joined: 26 Apr 2010, 17:36
Re: SELECT ROW based the newest date
Sorry bro but in my new query have a JOIN, can you mofify the query?
Tks
Code: Select all
SELECT [ANAGRAFICA].[IDCLI] & '-' & [PAGAMENTI].[COGNOME] & ' ' & [PAGAMENTI].[NOME] & '-(' & [ANAGRAFICA].[DTNASC] & ')' AS NOMINATIVO, ANAGRAFICA.INDIRIZZO, ANAGRAFICA.PR, ANAGRAFICA.CAP, ANAGRAFICA.COM_RES, [ANAGRAFICA].[IDALL] & '-' & [ANAGRAFICA].[TIPO_ALL] AS ALLENAMENTO, ANAGRAFICA.PERIODO, ANAGRAFICA.IL, ANAGRAFICA.QUOTA
FROM PAGAMENTI INNER JOIN ANAGRAFICA ON PAGAMENTI.IDCLI=ANAGRAFICA.IDCLI
WHERE ANAGRAFICA.IDCLI=68 AND PAGAMENTI.IDNR=20
-
- Administrator
- Posts: 80088
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4576
- Joined: 26 Apr 2010, 17:36
Re: SELECT ROW based the newest date
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 80088
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: SELECT ROW based the newest date
There is only 1 value of IL in both tables...
Best wishes,
Hans
Hans