Creating View with Records Limit

-1

I want to create a view that should only return a maximum of% with% registrations, regardless of the applied selection clauses . That is, whatever filter you apply, the number of rows should always be X . (with X does not seem to work, because so the result of the where clause registers will be less than X because the data will be restricted first to the universe within ROWNUM <= X ).

    
asked by anonymous 03.10.2016 / 18:11

1 answer

0

Using Analytic Functions , you create a rank and sort by it, the view goes on top of this.

    SELECT primeironome, Ident, Nome, Dt.Nasc, Local
FROM
(
SELECT a.ID AS Ident, 
       B.NOME AS Nome, 
       SUBSTR(TRIM(NOME),1,INSTR(TRIM(NOME),' ')) primeironome,
       TO_CHAR(DATNASC,'YYYY-MM-DD') AS Dt.Nasc, 
       LOCRESID AS Local,
       dbms_randam.value( vl_alea
       RANK() OVER (PARTITION BY primeironome  ORDER BY vl_alea)  rank 
FROM IDPESSOAL
) WHERE RANK < 11
    
05.10.2016 / 00:00