Sunday, July 12, 2020

SQL Micro - Top N View (from Oracle 19.6 onwards)

create or replace function top_n (
  num_rows number, tab dbms_tf.table_t
) return varchar2 sql_macro is
begin
  return 
    'select * from top_n.tab
     fetch first top_n.num_rows 
       rows only';
end;
/

select * from top_n(5,employees);

No comments:

Post a Comment