HOW TO GET ODD NUMBER ROWS IN A TABLE IN TERADATA

General
Enthusiast

HOW TO GET ODD NUMBER ROWS IN A TABLE IN TERADATA

Hi everyone,

Could you please attach the query for getting the odd rows in a table;

eg : id name sal 

       1 puru   2000k

       2 kiran   3000k

       3  hari    4000k

       4  mani    5000k

      5   suri      6000k

I need output as : 1 puru 2000k

                         3 hari    4000k

                          5  suri   6000k

5 REPLIES
Junior Supporter

Re: HOW TO GET ODD NUMBER ROWS IN A TABLE IN TERADATA

Hi:

SELECT * FROM TABLE WHERE ID MOD 2 = 1;

Cheers.

Carlos.

Enthusiast

Re: HOW TO GET ODD NUMBER ROWS IN A TABLE IN TERADATA

Sorry CarlosAL but where clause doesn't support OLAP functions.

Enthusiast

Re: HOW TO GET ODD NUMBER ROWS IN A TABLE IN TERADATA

Though you can use below query if you want odd number rows

SEL * FROM TBL_NAME QUALIFY SUM(1) OVER(ROWS UNBOUNDED PRECEDING) MOD 2 = 1 ;

and for even number rows use beow query

SEL * FROM TBL_NAME QUALIFY SUM(1) OVER(ROWS UNBOUNDED PRECEDING) MOD 2 = 0 ;

Enthusiast

Re: HOW TO GET ODD NUMBER ROWS IN A TABLE IN TERADATA

What application are you using and what RDBMS version are you on?

I'm curious why Carlos' solution did not work for you.

Rglass

Enthusiast

Re: HOW TO GET ODD NUMBER ROWS IN A TABLE IN TERADATA

I'm working on Teradata Sql Assistant 13.o version.