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 7707659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:24:58+00:00 2026-06-01T00:24:58+00:00

I am trying to build a query which will do this: Lets say for

  • 0

I am trying to build a query which will do this:
Lets say for example I have 100 records in the table. I have .net form which calls the query. I have a querystring parameter pageindex, something like http://mysite.com?id=2.
What I want to do now is if id = NULL, then get the 1st set of records from that table whichave id of 1 to 20, means from 1 to 20, if id=2 then get the 2nd set of recordw, from row 20 to 40, if id=3 then get the 3rd set of records, meaning records from 40 to 60, from that table.
I want to know if this is possible.
Thanks a lot in advance, Laziale

  • 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-06-01T00:24:59+00:00Added an answer on June 1, 2026 at 12:24 am

    If you make it as you say so, and the IDs are in line from 1 to 100 you can do

    @Page is the page number (base on 0)

    SELECT TOP 20 * FROM MyTable WHERE (ID > @Page*20) ORDER BY ID
    

    If you wish to use the paging style of Ms SQL and the ids are not in line you can do

    WITH NewTable AS (SELECT *, ROW_NUMBER() OVER (ORDER BY ID) AS RowNumber FROM MyTable)
    SELECT TOP 20 * FROM NewTable WHERE (RowNumber > @Page*20)
    

    Reference :
    http://msdn.microsoft.com/en-us/library/ms186734.aspx

    http://msdn.microsoft.com/en-us/library/ms175972.aspx

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

Sidebar

Related Questions

Given my following table structure: I'm trying to build a query that will return
Greetings all, I have a question. I am trying to build a parametrized query
Im trying to build a query that will fetch all changed rows from a
I'm trying to build a class which will initalise its self either by passing
I'm trying to build a query that will order results by date and time,
I'm trying to write Linq query on this Products table based on FacetTypes that
I am trying to figure out how to build a query, which satisfies the
Problem I am trying to build a small ruby script - which will be
I'm trying to build a query with hibernate criteria for the following scenario: Two
I am trying to build a CAML query for SharePoint 2007 environment, to get

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.