How to check the latest registration for the latest?

Asked

Viewed 31 times

0

have the following query sql - code below - and I would like to increment in it a "filter" of the most recent Insert so that the query is the latest pro Insert.

$sql = "
    select 
        ec.id_contrato,
        e.nome_entidade,
        c.valor_total_contrato,
        c.situacao,
        c.data_criacao
    from
        tb_entidade e, tb_entidade_contrato ec, tb_contrato c
    where
        e.id_entidade = ec.id_entidade
        and c.id_contrato = ec.id_contrato
        and ec.id_entidade_tipo = 1
    group by
        id_contrato, nome_entidade;
    ";

*I have a column called "data_creation" with type "datetime NULL [current_timestamp()]", I believe the filter can start from there.

for example:

inserir a descrição da imagem aqui

1 answer

-1


I think in the end you could add the command

ORDER BY c.data_creation DESC;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.