Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6613421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:12:59+00:00 2026-05-25T20:12:59+00:00

How do I get the offset of a particular row in a SQLite3 database?

  • 0

How do I get the offset of a particular row in a SQLite3 database? I am not talking about the ROWID, which is not linear, I am talking about the offset/position of a specific ROWID from the first ROWID in the table.

This is something like the SELECT COUNT(rowid) FROM table WHERE rowid < row, which returns the number of rows before the row identified with row. I feel that this is too slow, so I am hoping there is another way, faster than this, which will give me the offset/position of a row in a table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:13:00+00:00Added an answer on May 25, 2026 at 8:13 pm
    select top 1
       rowid
    from
       table
    where
      rowid < row
    order by
      rowid desc
    

    That should give you the largest rowid before your row. You could also try…

    select
       max(rowid)
    from
       table
    where
      rowid < row
    

    …But in my experience the first option performs better.

    If you just want the number of rows in front of your target row. Use…

    SELECT COUNT(1) FROM table WHERE rowid < row
    

    Basically what you had before, but don’t specify a column or else it is going to have to check that column for nulls while counting.

    Unfortunately, you don’t have access to the “ROW_NUMBER()” function like there is in MS SQL.

    (Similiar Question regarding SQLLite and numbering)

    sqlite equivalent of row_number() over ( partition by …?

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to get the offset from end row? Like some kind of
I am trying to get the offset hours from UTC, given a summer date.
I'm trying to get the offset or position of the cursor on a single
I would like to know how to get the distance/offset/position of an element relative
I want to get clients Time Zone offset from his IP address for my
i can't get this through. I need to get offset().top from a jquery object,
Given a pytz timezone for a particular user(calculated from his offset), i want to
i want to get the offset of the current cursor position the current selection
Mysql: i need to get the offset of a item in a query. I
How can I get the Timezone offset in Objective-C (for iPhone OS 3)? For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.