I have the following table T_PGTOS_ADESAO
:
Adesão | Tipo Adesão | Data Vencimento Boleto | Data Pgto Boleto
12247 | Cartão | 20-03-2018 | 03-03-2018
38497 | Boleto | 15-05-2018 | 10-05-2018
48289 | Cartão | 20-05-2018 | 02-01-1900
89497 | Saque Compl.| 23-04-2018 | 02-01-1900
90849 | Boleto | 15-05-2018 | 07-05-2018
I would like to create a column with the maximum date of the Ticket Date (which in the given example is the date 10-05-2018) for all lines, like this:
Adesão | Tipo Adesão | Data Vencimento Boleto |Data Pgto Boleto| DT_UTLIMO_PGTO
12247 | Cartão | 20-03-2018 | 03-03-2018 | 10-05-2018
38497 | Boleto | 15-05-2018 | 10-05-2018 | 10-05-2018
48289 | Cartão | 20-05-2018 | 02-01-1900 | 10-05-2018
89497 | Saque Compl.| 23-04-2018 | 02-01-1900 | 10-05-2018
90849 | Boleto | 15-05-2018 | 07-05-2018 | 10-05-2018
however when I make the query
SELECT
T_PGTOS_ADESAO.*,
MAX(Data Pgto Boleto) as DT_UTLIMO_PGTO
from T_PGTOS_ADESAO
GROUP BY
Adesão
,[Tipo Adesão]
,[Data Vencimento Boleto]
,[Data Pgto Boleto]
It returns the value of the Due Date Ticket for each line.
Could you please help me?