Oracle Rownum SQL -
what differences (advantages , disadvantages) between these 2 coding techniques?
select * ( select rownum rnun, * table rownum < x ) rnum > y select * ( select * table ) rownum < x , x > y
the 2 queries return different rows.
neither query deterministic. neither query should ever used in real system.
the first query appears @ least attempt generate window of rows (rows between x , y). since there no order by, however, order of rows not deterministic , window doesn't want.
the second query returns arbitrary x rows of data (assuming x > y). otherwise returns 0 rows (if y >= x). if you're trying build sort of windowing query, isn't it.
if want windowing query works, you'd want like
select * (select a.*, row_number() on (order something) rnum table_name) rnum between x , y
if wanted use rownum, you'd need like
select * (select a.*, rownum rnum from( select b.* table_name order something) a) rownum < y , rnum > x
but tends less efficient analytic query approach.
Comments
Post a Comment