-1
I want to create a view
that should only return a maximum of X
records, independent of the selection clauses applied. That is, whatever filter you apply, the number of lines should always be X
. (with the ROWNUM <= X
it does not seem to work because then the result of the records of the clause "Where" will be lower than X because the data will be restricted first to the universe under the ROWNUM <= X
).
And if the filter is restrictive to the point of not returning any record?
– Reginaldo Rigo
Records are selected by filter constraints and after that returns the number of records specified by the ROWNUM condition, if there are sufficient records.
– Reginaldo Rigo
If you select from the outside ?
– David
Select on the outside didn’t work. I want to always return such X records and with ROWNUM in the creation of the view and with the filter in select, the records that return, are less than those that actually exist.
– aper
Practical example: I have a table whose one of the attributes is the NAME of the employees; this NAME is part of the view I created; any query I make to that view should return at most 10 records; passing the solution through ROWNUM < 10 and executing a select restricting the name to "Pedros", the result will be the " Pedros" that exist in the first 10 records, but I wanted to return 10 "Pedros" (and in the table there are many more).
– aper
CREATE OR REPLACE V_VIEW AS SELECT COLUNA1,COLUNA2... FROM (SELECT COLUNA1,COLUNA2 FROM TABLE ORDER BY COLUNAN) WHERE ROWNUM < 1000
– Motta
The problem is that it is not possible to use "order by". Restricting another column other than "COLUNAN" to the query does not solve my problem.
– aper