0
I have a database with a table called config. In it I have the columns atributo, valor and data:
atributo              valor       data_atualizacao
juros_composto     |    5      |    2019-01-25
juros_fixo         |    6      |    2019-01-27
juros_fracionario  |    9      |    2019-01-28
juros_mediador     |    4      |    2019-01-30
juros_composto     |    12     |    2019-01-31
juros_fixo         |    14     |    2019-02-01
juros_fracionario  |    16     |    2019-02-02
juros_mediador     |    18     |    2019-02-03
I need to return the last attributes along with the values grouped by the update date, so the result should appear like this:
atributo                valor
juros_composto     |    12     |
juros_fixo         |    14     |
juros_fracionario  |    16     |
juros_mediador     |    18     |
I made a code like this:
SELECT valor MAX(data_atualizacao) FROM config GROUP BY atributo;
It returns the attributes without repeating (right) but the column 'VALUE' returns with the wrong data.
In case you want the last values registered in the Bank system ?
– Bulfaitelo
In the precise case of the last attribute values (without repeating) sorted by date. So for example, I have 4 types of attributes, I need to return the value of these attributes but only the most recent ones without repeating.
– matheus
I’ll send an answer with SQL see if it works,
– Bulfaitelo
OK.You can leave!
– matheus