dbTalk Databases Forums  

Rownum

comp.databases comp.databases


Discuss Rownum in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Andre Rothe
 
Posts: n/a

Default Rownum - 01-04-2008 , 05:11 AM






Hi,

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
Thanks a lot
Andre

Reply With Quote
  #2  
Old   
Lennart
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 07:33 AM






On Jan 4, 12:11 pm, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de>
wrote:
Quote:
Hi,

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
FYI, DB2 V9.5 has a compability mode that you can enable to ease
porting from Oracle. However, it is much better to use standard sql to
express the same thing:

select * from (
select row_number() over (order by a,b,c) as t, a,b,c,d from
datatable
where c=1
) as X where t=15

The name of the subquery is not necessary according to the standard,
but DB2 (V9) requires it.

HTH
/Lennart


Reply With Quote
  #3  
Old   
Lennart
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 07:33 AM



On Jan 4, 12:11 pm, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de>
wrote:
Quote:
Hi,

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
FYI, DB2 V9.5 has a compability mode that you can enable to ease
porting from Oracle. However, it is much better to use standard sql to
express the same thing:

select * from (
select row_number() over (order by a,b,c) as t, a,b,c,d from
datatable
where c=1
) as X where t=15

The name of the subquery is not necessary according to the standard,
but DB2 (V9) requires it.

HTH
/Lennart


Reply With Quote
  #4  
Old   
Lennart
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 07:33 AM



On Jan 4, 12:11 pm, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de>
wrote:
Quote:
Hi,

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
FYI, DB2 V9.5 has a compability mode that you can enable to ease
porting from Oracle. However, it is much better to use standard sql to
express the same thing:

select * from (
select row_number() over (order by a,b,c) as t, a,b,c,d from
datatable
where c=1
) as X where t=15

The name of the subquery is not necessary according to the standard,
but DB2 (V9) requires it.

HTH
/Lennart


Reply With Quote
  #5  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 12:36 PM



On Jan 4, 6:11*am, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de>
wrote:
Quote:
Hi,

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
Thanks a lot
Andre
ROWNUM is assigned BEFORE the ORDER BY. it is a kludge and IMHO an
abomination.

you are better off using the ranking functions as Lennart mentioned.
Ed


Reply With Quote
  #6  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 12:36 PM



On Jan 4, 6:11*am, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de>
wrote:
Quote:
Hi,

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
Thanks a lot
Andre
ROWNUM is assigned BEFORE the ORDER BY. it is a kludge and IMHO an
abomination.

you are better off using the ranking functions as Lennart mentioned.
Ed


Reply With Quote
  #7  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 12:36 PM



On Jan 4, 6:11*am, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de>
wrote:
Quote:
Hi,

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
Thanks a lot
Andre
ROWNUM is assigned BEFORE the ORDER BY. it is a kludge and IMHO an
abomination.

you are better off using the ranking functions as Lennart mentioned.
Ed


Reply With Quote
  #8  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 03:39 PM



Ed Prochak <edprochak (AT) gmail (DOT) com> wrote:

Quote:
On Jan 4, 6:11*am, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de
wrote:

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
Thanks a lot
Andre

ROWNUM is assigned BEFORE the ORDER BY. it is a kludge and IMHO an
abomination.

you are better off using the ranking functions as Lennart mentioned.
I agree with Ed, except for the bit of it being his humble
opinion that it is an abomination. It *IS* an abomination.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #9  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 03:39 PM



Ed Prochak <edprochak (AT) gmail (DOT) com> wrote:

Quote:
On Jan 4, 6:11*am, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de
wrote:

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
Thanks a lot
Andre

ROWNUM is assigned BEFORE the ORDER BY. it is a kludge and IMHO an
abomination.

you are better off using the ranking functions as Lennart mentioned.
I agree with Ed, except for the bit of it being his humble
opinion that it is an abomination. It *IS* an abomination.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
  #10  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: Rownum - 01-04-2008 , 03:39 PM



Ed Prochak <edprochak (AT) gmail (DOT) com> wrote:

Quote:
On Jan 4, 6:11*am, Andre Rothe <andre.ro... (AT) imise (DOT) uni-leipzig.de
wrote:

Did anyone knows a database system which can execute the following query:

select *
from (select rownum t, a, b, c, d from datatable where c=1 order by a,b,c)
where t=15

In Oracle I get the 15th row of the subquery, but I cannot find another
system which has implemented the rownum functionality like Oracle.

Ideas?
Thanks a lot
Andre

ROWNUM is assigned BEFORE the ORDER BY. it is a kludge and IMHO an
abomination.

you are better off using the ranking functions as Lennart mentioned.
I agree with Ed, except for the bit of it being his humble
opinion that it is an abomination. It *IS* an abomination.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.