I am trying to run a query with Access. Each customer may have multiple revisions of the same 'widget'. Not all customers require the same revision, e.g. - CustomerA was entered in column 'ID' as 10, 13, and 34 - 34 contains the data I want to see without seeing entry 10 and 13 - each 'ID' has the date it was entered and the same 'widget#' - so 10, 13, and 34 show 'Entry#''widget42''rev#''customerA''date entered'. Likewise, 'CustomerC' only has 1 entry. (The 1st revision is usually left blank, i.e. - some do not say Rev. 0, the cell is just blank.) So, 'customerC' would look like this - 'Entry#''widget42''rev# (may be blank)''customerC''date entered'. What I want is to only see the latest revision for each customer for any one widget, all customers on one page with all their latest revised widget (no repeat widgets per customer).
'Entry#'--'widget#'--'rev#'--'customer#'--'date entered'
'10'------'widget42'-' '--'Brazil'-----'08/19/1999'
'13'------'widget42'-'Rev 1'-'Brazil'-----'05/08/2001'
'20'------'widget5'--' '--'Ireland'----'09/12/2001'
'26'------'widget6'--' '--'Brazil'-----'12/01/2001'
'30'------'widget5'--'Rev 1'-'Ireland'----'10/30/2003'
'33'------'widget42'-' '--'Ireland'----'11/16/2005'
'34'------'widget42'-'Rev 2'-'Brazil'-----'05/14/2006'
'43'------'widget23'-' '--'Peru'-------'06/16/2006'
'54'------'widget6'--' '--'Ireland'----'06/17/2006'
WHAT I WOULD LIKE TO SEE ---------------------------- POSSIBLY SORTED BY CUSTOMER ----- AFTER RETURNING ONLY LATEST REVISION NUMBER
'Entry#'--'widget#'--'rev#'--'customer#'--'date entered'
'20'------'widget5'--' '--'Ireland'----'09/12/2001'
'26'------'widget6'--' '--'Brazil'-----'12/01/2001'
'30'------'widget5'--'Rev 1'-'Ireland'----'10/30/2003'
'33'------'widget42'-' '--'Ir开发者_开发技巧eland'----'11/16/2005'
'34'------'widget42'-'Rev 2'-'Brazil'-----'05/14/2006'
'43'------'widget23'-' '--'Peru'-------'06/16/2006'
'54'------'widget6'--' '--'Ireland'----'06/17/2006'
You could base your report on a query, say:
SELECT w.entry, w.widget, w.revx,
w.customer, w.date_entered
FROM
(SELECT entry, widget, Nz([rev],"rev0") AS revx,
customer, date_entered
FROM widgets) w
INNER JOIN (SELECT customer, widget, Max(Nz(rev,"rev0")) As revx
FROM widgets
GROUP BY customer, widget) AS a
ON (w.widget = a.widget) AND (w.customer = a.customer) AND (w.revx=a.revx)
精彩评论