Skip to content

Instantly share code, notes, and snippets.

@nolstedt
Last active December 14, 2015 14:19
Show Gist options
  • Save nolstedt/5100135 to your computer and use it in GitHub Desktop.
Save nolstedt/5100135 to your computer and use it in GitHub Desktop.
Oracle rownum vs Postgres
create table rownum_tst (
id integer,
vc varchar(20)
);
insert into rownum_tst(id,vc) values(1,'4');
insert into rownum_tst(id,vc) values(2,'4,5');
select * from
(select rownum as position, vc from rownum_tst)
where vc = '4,5';
--postgres gives 1 4,5
--ora gives 2 4,5
--change into to give same result
select * from
(select row_number() OVER (order by id) as position, vc from rownum_tst)
where vc = '4,5';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment