A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Show Last 20 rows



 
 
Thread Tools Display Modes
  #1  
Old July 12th, 2008, 09:23 PM posted to microsoft.public.access.gettingstarted
Kevin
external usenet poster
 
Posts: 910
Default Show Last 20 rows

Hi,

how to get the last 20 rows only in one column contain 1000 rows
  #2  
Old July 13th, 2008, 12:18 AM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 2,364
Default Show Last 20 rows

First, define the last twenty rows? Data is not stored in any specific
order. If you want the last 20 rows there must be something in a field
(or fields) that specifies that this row is one of the last 20?

Another way to think about that is there must be a field or fields that
you can sort by that will put the records in an order so that the last
20 rows can be picked.

Take a look at using TOP 20 in a query that orders the rows in the
manner you want.

An SQL statement to do this might look like the following:
SELECT Top 20 *
FROM YourTable
ORDER BY EntryDateTimeField, PrimaryKeyField



'================================================= ===
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'================================================= ===


Kevin wrote:
Hi,

how to get the last 20 rows only in one column contain 1000 rows

  #3  
Old July 14th, 2008, 06:24 AM posted to microsoft.public.access.gettingstarted
Kevin
external usenet poster
 
Posts: 910
Default Show Last 20 rows

Hi,

Thanks for advise....!

but still can't understand...? below is the table i using to colect
measurement data.
i just want get the latest 5 measurement only meaing from 5 to 10 row.

Please advise

id | Measure |
-----------------
1 0.45
2 0.50
3 0.41
4 0.42
5 0.40
6 0.30
7 0.46
8 0.42
9 0.43
10 0.40


"John Spencer" wrote:

First, define the last twenty rows? Data is not stored in any specific
order. If you want the last 20 rows there must be something in a field
(or fields) that specifies that this row is one of the last 20?

Another way to think about that is there must be a field or fields that
you can sort by that will put the records in an order so that the last
20 rows can be picked.

Take a look at using TOP 20 in a query that orders the rows in the
manner you want.

An SQL statement to do this might look like the following:
SELECT Top 20 *
FROM YourTable
ORDER BY EntryDateTimeField, PrimaryKeyField



'================================================= ===
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'================================================= ===


Kevin wrote:
Hi,

how to get the last 20 rows only in one column contain 1000 rows


  #4  
Old July 14th, 2008, 12:15 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default Show Last 20 rows

Open a new query in design view (the query grid)
Add your table
Add ID and Measure to the fields
Sort by ID in descending order
Double click on a blank area of the top section
You should see Query Properties sheet
Change Top Values to 5 (if you want the top 5)


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

Kevin wrote:
Hi,

Thanks for advise....!

but still can't understand...? below is the table i using to colect
measurement data.
i just want get the latest 5 measurement only meaing from 5 to 10 row.

Please advise

id | Measure |
-----------------
1 0.45
2 0.50
3 0.41
4 0.42
5 0.40
6 0.30
7 0.46
8 0.42
9 0.43
10 0.40


"John Spencer" wrote:

First, define the last twenty rows? Data is not stored in any specific
order. If you want the last 20 rows there must be something in a field
(or fields) that specifies that this row is one of the last 20?

Another way to think about that is there must be a field or fields that
you can sort by that will put the records in an order so that the last
20 rows can be picked.

Take a look at using TOP 20 in a query that orders the rows in the
manner you want.

An SQL statement to do this might look like the following:
SELECT Top 20 *
FROM YourTable
ORDER BY EntryDateTimeField, PrimaryKeyField



'================================================= ===
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'================================================= ===


Kevin wrote:
Hi,

how to get the last 20 rows only in one column contain 1000 rows

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.