SQL - Set Timestamp in Select

Asked

Viewed 31 times

-2

How do I set the min("Timestamp") in a select and then return the last data where it is different from this min("Timestamp")?

My Code:

SELECT min("TIMESTAMP") AS PrimeiroLog, ID, UF
FROM bd.test
WHERE "TIMESTAMP" != PrimeiroLog

My select was to return the cases in yellow

Exemplo

1 answer

1

--minino
select min("timestamp")
from teste

--maior que 
select *
from teste t1
where "timestamp" > (select min("timestamp")
                     from teste t2
                     where t2.uf = t1.uf)

Browser other questions tagged

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