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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Last record/entry from a table



 
 
Thread Tools Display Modes
  #1  
Old June 2nd, 2010, 03:26 PM posted to microsoft.public.access.queries
Hurrikane4
external usenet poster
 
Posts: 12
Default Last record/entry from a table

My table has three columns, AcctNum, TransDate, SeqNum
I need a query that only displays the last "SeqNum" when an "AcctNum" had
multiple entries on the same day.

For example, my table has the following data:
AcctNum TransDate SeqNum
1234 6/2/10 698
1234 6/2/10 701
1234 6/2/10 705

In this case, I only want the see the one row with the highest "SeqNum"
(which is #705).

Thank you, in advance, for your help, I do appreciate it.
  #2  
Old June 2nd, 2010, 03:49 PM posted to microsoft.public.access.queries
Bob Barrows
external usenet poster
 
Posts: 475
Default Last record/entry from a table

Hurrikane4 wrote:
My table has three columns, AcctNum, TransDate, SeqNum
I need a query that only displays the last "SeqNum" when an "AcctNum"
had multiple entries on the same day.

For example, my table has the following data:
AcctNum TransDate SeqNum
1234 6/2/10 698
1234 6/2/10 701
1234 6/2/10 705

In this case, I only want the see the one row with the highest
"SeqNum" (which is #705).

Thank you, in advance, for your help, I do appreciate it.


If SeqNum is unique, then
select AcctNum,TransDate, ...
from yourtable as t join
(select AcctNum, TransDate,Max(SeqNum) As MaxSeqNum
FROM yourtable GROUP BY AcctNum, TransDate ) as q
ON t.AcctNum=q.AcctNum and t.TransDate=q.TransDate
and SeqNum = MaxSeqNum

--
HTH,
Bob Barrows


  #3  
Old June 2nd, 2010, 03:58 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Last record/entry from a table

Try this SQL --
SELECT AcctNum, TransDate, Max([SeqNum]) AS Last_SeqNum
FROM YourTable
GROUP BY AcctNum, TransDate;

Or in design view grid --
FIELD : AcctNum TransDate SeqNum
Table: YourTable YourTable YourTable
Total: Group By Group By Maximum


--
Build a little, test a little.


"Hurrikane4" wrote:

My table has three columns, AcctNum, TransDate, SeqNum
I need a query that only displays the last "SeqNum" when an "AcctNum" had
multiple entries on the same day.

For example, my table has the following data:
AcctNum TransDate SeqNum
1234 6/2/10 698
1234 6/2/10 701
1234 6/2/10 705

In this case, I only want the see the one row with the highest "SeqNum"
(which is #705).

Thank you, in advance, for your help, I do appreciate it.

 




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 11:54 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.