All Forums General
Purushotham 87 posts Joined 04/14
09 Jun 2015
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
 
 

Purushotham.M
CarlosAL 512 posts Joined 04/08
10 Jun 2015

Hi:
SELECT * FROM TABLE WHERE ID MOD 2 = 1;
Cheers.
Carlos.

gera_g 3 posts Joined 02/14
08 Jul 2016

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

gera_g 3 posts Joined 02/14
08 Jul 2016

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 ;

Glass 225 posts Joined 04/10
08 Jul 2016

What application are you using and what RDBMS version are you on?
I'm curious why Carlos' solution did not work for you.
 
Rglass

You must sign in to leave a comment.