sql - Select n number of records from oracle database -


i have select n number of rows oracle database sap using native sql. in open sql query

    select * mydb size > 2000 upto n rows. 

what learnt other posts equivalent native sql query

    select * mydb size > 2000 , rownum <= 100 

is correct?

do need have rownum 1 of fields in db table?

rownum pseudocolumn generated oracle whenever perform select. assignment of value rownum last thing done before query returns row - thus, first row emitted query given rownum = 1, second row emitted query given rownum = 2, , on. notice: means statement following return no rows:

select *   some_table   rownum >= 2 

why return no rows? it's because first row emitted query given rownum = 1, , since query looking rows rownum >= 2 no rows selected because first rownum value of 1 applied first row emitted.

however - if really want rows except first (or first 10, or have you) can this:

select *   (select *, rownum inner_rownum           some_table           = something_else           order whatever)   i.inner_rownum in (1, 2, 3, 5, 7, 11, 13, 17, 19); 

here use inner select gets rows given condition (something = something_else) , assigns rownum inner query computed column named inner_rownum, can use normal column in outer query.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -