cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch column values based on Rowid

0 Kudos

Hello,

  If I want to get the value of let us say the 1st, 1000th, 2000th entry of a particular field, how should I go about. I tried with the below logic. It did not work for me.

  

   select belnr, row_number () over (order by "BELNR") as ROWN from sapshh.bseg where mod( ROWN, 1000 ) = 0

  

SAP DBTech JDBC: [260] (at 94): invalid column name: ROWN: line 2
col 32 (at pos 94)

I am able to fetch the values of the row_numbers of the rows I select however. The below query returns what I need. But when I use row_number in the where condition, it does not work.

select carrid, row_number () over (order by "CARRID") as ROWN from sapshh.spfli

I also tried with $rowed$ and I get the below error:

select "$rowid$" FROM "SAPSHH"."DD02L" WHERE mod("$rowid$", 10000 ) = 0

Could not execute 'select tabname,
"$rowid$" FROM "SAPSHH"."DD02L" WHERE
mod("$rowid$", 10000 ) = 0' in 369 ms 23 µs .

SAP DBTech JDBC: [2048]: column store error: search table error:
[6901] Attribute engine function not implemented

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor
0 Kudos

Don't use $rowid$. Like, ever!

What you want to do is likely this:

select row_num, belnr

from

  (select row_number() over (order by belnr asc) row_num, belnr

  from bseg)

where mod(row_num, 1000) = 0;

Answers (1)

Answers (1)

amol_samte
Contributor
0 Kudos

Hi Rajeev,

Have you tried this.

select * from

     (

          select belnr, row_number() over(partition by belnr ) as ROWNUM

          from sapshh.bseg

     )

   

where = rownum in (1, 1000, 2000);

-Amol S

0 Kudos

Thanks a lot Amol and Lars.

Regards,

Rajeev