Reputation: 2639
In Oracle you can do:
select
rownum, -- here's the magic
name as country,
population as pop_mil
from
country
where
name like 'C%' and
member = true
order by
population;
and get
rownum country pop_mil
------ -------- -------
1 Croatia 5
2 Chad 11
3 Cuba 11
4 Canada 35
5 Colombia 48
6 China 1360
Note that rownum has no relation to how rows are stored in the table. It's a pseudocolumn that enumerates the rows in the resulset after all filters and sort operations are done.
I know there's a workaround (row_number() over ...
) in versions >= 8.4 (here), but my database is 8.3 and ther're no plans of migrating anytime soon.
- Is there a way to do that in PostgreSQL 8.3 ?
Upvotes: 2
Views: 549