How to create a sub-select in oracle in a composite key table?

Asked

Viewed 309 times

0

The table has a composite primary key, and the fields are a date (ID_DEPURACAO) and a number(SEQ_DEPURACAO).

What I want to do is a sub-select that takes only data greater than a given date and that has sequences from a certain number.

Keep going like I’m trying to do:

SELECT count(*) 
from OBJETOEXEMPLO.TABELAEXEMPLO
where (id_depuracao > to_date ('26/03/2016','dd/mm/yyyy') 
  and id_depuracao <= to_date ('30/06/2016','dd/mm/yyyy'))
  and seq_depuracao > 1999357
order by id_depuracao asc; 

Att..

1 answer

0

Something like

Select *
From tabela t1
Where ...
And data = ( select max(data)
             From tabela t2
             Where t2.chave1 = t1.chave1
             And t2.chave2 = t1.chave2)

Browser other questions tagged

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