Home » SQL & PL/SQL » SQL & PL/SQL » How to get even rows!.
How to get even rows!. [message #20006] Wed, 24 April 2002 01:11 Go to next message
karunamoorthy_p
Messages: 13
Registered: April 2002
Junior Member
Please help me to get the following query:

Using simple select statement, how to retrieve the
even rows.
Re: How to get even rows!. [message #20008 is a reply to message #20006] Wed, 24 April 2002 01:58 Go to previous messageGo to next message
even
Messages: 1
Registered: April 2002
Junior Member
this'll do :

select * from
(select rownum rn , id .... from your_Table )
where mod(rn,2)=0
Be carefull with rownum [message #20010 is a reply to message #20006] Wed, 24 April 2002 04:09 Go to previous messageGo to next message
Mike
Messages: 417
Registered: September 1998
Senior Member
Be carefull with rownum. There is no rownum stored in the database, the rownum is generated when you execute your query. So depending on how your query is executed you may get a different rownum for the same row.
Re: How to get even rows!. [message #20011 is a reply to message #20006] Wed, 24 April 2002 04:22 Go to previous messageGo to next message
Be carefull with rownum
Messages: 1
Registered: April 2002
Junior Member
Be carefull with rownum. There is no rownum stored in the database, the rownum is generated when you execute your query. So depending on how your query is executed you may get a different rownum for the same row.
Re: How to get even rows!. [message #20015 is a reply to message #20006] Wed, 24 April 2002 07:51 Go to previous message
sridhar
Messages: 119
Registered: December 2001
Senior Member
SELECT * FROM
(SELECT * From emp
ORDER BY column_name) -- column name plays major role
WHERE mod(rownum, 2) = 0

You want order the table first based on a column and then fetch every 2nd row. Otherwise the purpose is lost.
SriDHAR
Previous Topic: Simple Sql Query...
Next Topic: SQL question
Goto Forum:
  


Current Time: Fri Apr 19 03:16:56 CDT 2024