By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,157 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,157 IT Pros & Developers. It's quick & easy.

DElete Top XXX Query

P: 34
Hi all.. i have 200 record in my database.. and i want to delete the top 100 of them when i arrange it in ascending order.... btw i'm using ms access ..

The problem: what is the SQL instruction for this... can it be done?

Thanks in advance..:)
Jan 30 '08 #1
Share this Question
Share on Google+
5 Replies


lotus18
100+
P: 866
Hi all.. i have 200 record in my database.. and i want to delete the top 100 of them when i arrange it in ascending order.... btw i'm using ms access ..

The problem: what is the SQL instruction for this... can it be done?

Thanks in advance..:)
Hi

You can post your thread at the Database > Access forum in whch they can assist you better : )

Rey Sean
Jan 30 '08 #2

P: 34
Hi

You can post your thread at the Database > Access forum in whch they can assist you better : )

Rey Sean
Hi rey..

Thanks for the advice.. but i just need to know the sql code for the operation... i'll use it in my vb code.. to do the operation in my access databse.. i just want to make sure wether such operation can be done using sql code.. i think it can be done if i have the right code...

SELECT TOP 100 *
FROM Transact2
ORDER BY File_no DESC

if we were to retrieve top 100 data.. can we delete that top 100?

need some light... hmm
Jan 30 '08 #3

jamesd0142
100+
P: 469
not tested, but im sure its in the right area:

Expand|Select|Wrap|Line Numbers
  1. delete from customers where cust_id in (select top 3 cust_id from customers)
  2.  
Jan 30 '08 #4

P: 34
not tested, but im sure its in the right area:

Expand|Select|Wrap|Line Numbers
  1. delete from customers where cust_id in (select top 3 cust_id from customers)
  2.  

Thanks james.. Will try..
Jan 30 '08 #5

P: 34
Thanks james.. Will try..
hEY JAMES . Thanks a lot,.. tried and suceeded...

DELETE
FROM (SELECT TOP 1000 *
FROM Transact2
where Check_out IS NOT NULL
order by Check_in )


with a bit of alteration... u make my day..thanks again..
Jan 30 '08 #6

Post your reply

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