Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to fetch column values based on Rowid

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

Tags:
Former Member
replied

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;

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question