473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

This should be easy, shouldn't it? Not Min query

Hi,

I have a table which will have records appended to it weekly. In my append query I have a field to identify when it was appended using Now(). Now what I want to do is delete the identical records that were appended later so each record should only appear when they were appended for the first time.

So I basically am trying to select all the records that are not MIN on the appended date so I can then turn it into a delete query. I hope this is clear? How would I do this?

Your help is much appreciated.
Feb 27 '09 #1
11 1494
FishVal
2,653 Expert 2GB
Make an aggregating query returning "min" records for each group.
Use "... WHERE ... Not In ..." syntax in your delete query.

Regards,
Fish.
Feb 27 '09 #2
I am fumbling around SQL and it's not doing what it's told. If I gave a mini example of the situation, maybe you could help with the SQL.

Table appeded records go into = "DMH"
Field identifying when record each record was appended = "Updated Date"
Other fields include = "Name", "ADM_AOS_CODE", "Email"

Query selecting earliest Appended records, the records I want to keep = "DMEU"
Feb 27 '09 #3
FishVal
2,653 Expert 2GB
What field defines record groups from which earliest records are to be returned?
Feb 27 '09 #4
That is the "Updated Date" field. I run the MIN function on this with all other fields in my table in the query. Did I understand you correctly?
Feb 27 '09 #5
FishVal
2,653 Expert 2GB
Does it mean there is only one record to keep?
Feb 27 '09 #6
No, because the "Name" can be different etc.
Feb 27 '09 #7
FishVal
2,653 Expert 2GB
Ok. [Name] defines group from which earliest record is kept.
Is any from the rest fields a part of group definition?
Feb 27 '09 #8
Sorry. To be specific: [ADM_ID] will be the field that will define the group.
Feb 27 '09 #9
FishVal
2,653 Expert 2GB
Something like the following

Query: qryRecordsToKeep

Expand|Select|Wrap|Line Numbers
  1. SELECT [ADM_ID], Min([Updated Date]) AS dteEarliestDate FROM [DMH] GROUP BY [ADM_ID];
  2.  
Expand|Select|Wrap|Line Numbers
  1. DELETE * FROM [DMH]
  2. WHERE [ADM_ID] Not In (SELECT dteEarliestDate FROM qryRecordsToKeep
  3. );
  4.  
Regards,
Fish
Feb 27 '09 #10
Excellent. Thankyou very much!
Feb 27 '09 #11
FishVal
2,653 Expert 2GB
You are welcome.
Feb 27 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
I had some code that worked fine for several weeks, and then yesterday it stopped working. I'm not sure what I did. Nor can I make out why it isn't working. I'm running a query that should return 3...
16
by: Thomas G. Marshall | last post by:
This message is sent to these newsgroups because they are no longer valid: comp.lang.java comp.lang.java.api comp.lang.java.bugs comp.lang.java.misc comp.lang.java.setup comp.lang.java.tech
2
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: August 28, 2002 Version: 1.15 URL: http://css.nu/faq/ciwas-aFAQ.html...
0
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/authoring-faq Posting-Frequency: twice a week (Mondays and Thursdays) Last-modified: April 10, 2003 Version: 1.16 URL: http://css.nu/faq/ciwas-aFAQ.html Maintainer:...
7
by: Tim | last post by:
hi all, I have a table of customers. I have a table of products they have ordered. How can I find all customers who have ordered productA and productB at any time. It sounds so easy, but...
2
by: Shapper | last post by:
Hello, I have the function changeCulture(culture As String) in all my .aspx web pages. This functions changes Threat Culture among other actions. So the new culture takes effect I need to...
24
by: Gaijinco | last post by:
I found one of that problems all of us have solve when they begin programming: given 3 numbers print the greater and the lesser one of the set. I was trying to remember the if-then-else...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
3
by: MorrganMail | last post by:
Recently got to take over the responisibility for an application which is making heavy use of an Access database. It has been a long time since I came in contact with anything database related and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.