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.
|
|
0
|
|
|
|
Reply
|
Utf
|
6/2/2010 2:26:06 PM |
|
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
|
|
0
|
|
|
|
Reply
|
Bob
|
6/2/2010 2:49:01 PM
|
|
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.
|
|
0
|
|
|
|
Reply
|
Utf
|
6/2/2010 2:58:01 PM
|
|
|
2 Replies
535 Views
(page loaded in 0.077 seconds)
Similiar Articles: Last record/entry from a table - microsoft.public.access.queries ...My table has three columns, AcctNum, TransDate, SeqNum I need a query that only displays the last "SeqNum" when an "AcctNum" had multiple entries o... last entry per record query.. - microsoft.public.access.queries ...Hi and thanks for your time. My database is tracking the service histroy of vehicles. The main table has VIN as the PK which links to another tabl... Enter Data from a Form into a Table - microsoft.public.access ...#2) I am wondering if there is an easy way to add new records to a Table ... not in data entry - maybe read-only?) #2) In Data Entry mode, tabbing out of the last record ... What function will return the most recent entry date for a record ...Last record/entry from a table - microsoft.public.access.queries ... What function will return the most recent entry date for a record ... Last records from a ... function ... Getting value from previous record - microsoft.public.access ...I have the sum of apples in my last record and want to subtract apples ... Last record/entry from a table - microsoft.public.access.queries ... Getting value from ... Copy 3 separate records from form into 1 row of table as new entry ...Append one record into a table from form fields - microsoft.public ... Copy 3 separate records from form into 1 row of table as new entry ..... from the last form field in ... Last records from a Group By query - microsoft.public.access ...Last record/entry from a table - microsoft.public.access.queries ... My table has three columns, AcctNum, TransDate, SeqNum I need a query that only displays the last ... Repeating entries on form - microsoft.public.access.formscoding ...Last record/entry from a table - microsoft.public.access.queries ... Repeat data from previous records in a form - microsoft.public ... I am creating a a form for data ... Finding Average of last 5 entries - microsoft.public.excel ...Entry into One form ... Record To ... Group in Query I'm working with a table that has daily entries per item. I'm trying to pull the last 5 dates (records ... multiple entries of the same song - microsoft.public.windowsmedia ...Column B contains a timestamp. My table has multiple entries for eac... ... the vlookup function to check a table which may or may not have multiple rows for the same ... Get data from the last entry on a table: last, get, entry, recordHi i want to know the value of the last record inserted on a table, just before the insert into. It has an auto inc value that i need to know. Tx all 8/1/2012 8:06:45 AM
|