Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8291553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:10:07+00:00 2026-06-08T13:10:07+00:00

MS ACCESS SQL DELETE * FROM Lane_Details WHERE Lane_Details.Week not in(SELECT DISTINCT TOP 3

  • 0

MS ACCESS SQL

DELETE * 
FROM Lane_Details
WHERE Lane_Details.Week not in(SELECT DISTINCT TOP 3 Lane_Details.Week
           FROM Lane_Details
WHERE Lane_Details.Week IS NOT NULL
ORDER BY Week DESC; )

DESIRED OUTCOME

What I need this to do is delete anything out of the table that is 4 weeks old or older.

I have been having trouble with the not in. it cause Access to completely lock up. I am not sure what the correct syntax should be for this, and I know that I can write it with a left outer join but I don’t know how to do that.

DATA

ID            Lane  Time                        Week
6213214 83198524    4/6/2012 12:31:00 AM    201315
6213183 61780698    4/6/2012 12:31:00 AM    201311
6213201 11145552    4/6/2012 12:31:00 AM    201315
6213202 82391025    4/6/2012 12:31:00 AM    201314
6213203 11149012    4/6/2012 12:31:00 AM    201311
6213204 11140048    4/6/2012 12:31:00 AM    201311
6213205 83198524    4/6/2012 12:31:00 AM    201316
6213207 61625652    4/6/2012 12:31:00 AM    201316
6213210 61625652    4/6/2012 12:31:00 AM    201311
6637195 36166433    5/1/2012 8:25:00 AM           201314
6637206 77222091    5/1/2012 10:50:00 AM    201314

With this data, I would want to delete any row that has Week 201311. I want to keep 201314, 201315, and 201316.

The subquery will run on this table, and grab the top 3 dates (14, 15, 16) in this case. I then say “not in” to delete all the 11’s.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:10:08+00:00Added an answer on June 8, 2026 at 1:10 pm

    Thanks for all of the help. I finally realized that it wasn’t my query, it just ran really slow. I think it was a performance issue. I decided to break the query down into a few different ones. It is working much better now. i eventually found this website and came to that conclusion.

    VBA isnt the best place to do sub queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can anyone tell how to access MS SQL Server from objective c programatically
I would like to use integrated authentication to access a SQL database from a
I'm trying to transfer some data from Access to SQL Server 2000 (there are
I ran a SQL Delete from a SQL Developer session and the delete was
Im copying data from a ms access db to sql server like this... string
Unfortunately we do not have the required DCOM access to the SQL Server mentioned
While trying to delete the data from my SQL Server CE 3.5 database, I
I have a link from Microsoft Access to a SQL Server table. The I/O
I'm running the following SAS command: Proc SQL; Delete From Server003.CustomerList; Quit; Which is
When working in Access, whenever I delete a record from one table - it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.