Re: How to retrieve rows from position n to position m from table in Access 2003



Hi, Orgil.

For example: I have a table "Notes". Which has 37 rows and I need to
get rows from 20th to 30th

I tried this:
SELECT TOP 30 * FROM Notes
WHERE [id] NOT IN
(SELECT TOP 20 [id] FROM Notes ORDER BY [id]) ORDER BY [id];

This will give you the next 30 rows after #20 (it stops at #37, because
that's the last row, so you only get 17 rows in this table, not 30), but you
only need the 10 rows (30th - 20th) between row #21 and #30, inclusive.
Change the TOP 30 to TOP 10. For example:

SELECT TOP 10 * FROM Notes
WHERE ID NOT IN
(SELECT TOP 20 ID FROM Notes ORDER BY ID) ORDER BY ID;

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.


.



Relevant Pages

  • Re: Access 2007 - Security
    ... See http://www.QBuilt.com for all your database needs. ... See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials. ... Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com ...
    (microsoft.public.access.security)
  • Re: Workgroup file has disappeared?
    ... See http://www.QBuilt.com for all your database needs. ... See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials. ... Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com ...
    (microsoft.public.access.formscoding)
  • Re: global search of the MSysQueries table
    ... See http://www.QBuilt.com for all your database needs. ... See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials. ... Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com ...
    (comp.databases.ms-access)
  • Re: Database Options - Any other settings I should adjust?
    ... See http://www.QBuilt.com for all your database needs. ... See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials. ... Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com ...
    (comp.databases.ms-access)
  • Re: Compile error when converting from A2003 to A2007
    ... See http://www.QBuilt.com for all your database needs. ... See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials. ... Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com ...
    (microsoft.public.access.conversion)