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  

Removing duplicate items within a category



 
 
Thread Tools Display Modes
  #1  
Old February 19th, 2007, 08:25 PM posted to microsoft.public.access.queries
Mtnbiker
external usenet poster
 
Posts: 1
Default Removing duplicate items within a category

Hi,

I have a table which appears below:

ITEM PRICE DATE
Paper clips 0.89 2/2/06
Paper clips 1.29 2/12/07
Stapler 2.57 12/29/05
Stapler 2.99 1/5/07

How do I write a query which will show the most recent cost for each item? I
am hoping for a result as shown below:

ITEM PRICE DATE
Paper clips 1.29 2/12/07
Stapler 2.99 1/5/07

Thanks in advance for your help!
  #2  
Old February 19th, 2007, 09:13 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Removing duplicate items within a category

One way

SELECT ITEM, PRICE, [Date]
FROM [Yourtable]
WHERE [YourTable].[Date] =
(SELECT Max([Date])
FROM [YourTable] as Temp
WHERE Temp.Item = [YourTable].Item

If that is too slow, post back with a copy of the SQL (View: SQL) and I'll
suggest a faster but more complex alternative.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Mtnbiker" wrote in message
...
Hi,

I have a table which appears below:

ITEM PRICE DATE
Paper clips 0.89 2/2/06
Paper clips 1.29 2/12/07
Stapler 2.57 12/29/05
Stapler 2.99 1/5/07

How do I write a query which will show the most recent cost for each item?
I
am hoping for a result as shown below:

ITEM PRICE DATE
Paper clips 1.29 2/12/07
Stapler 2.99 1/5/07

Thanks in advance for your help!



 




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 08:32 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.