DElete Top XXX Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GROG
    New Member
    • Sep 2007
    • 34

    DElete Top XXX Query

    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..:)
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Originally posted by GROG
    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

    Comment

    • GROG
      New Member
      • Sep 2007
      • 34

      #3
      Originally posted by lotus18
      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

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        not tested, but im sure its in the right area:

        [code=sql]
        delete from customers where cust_id in (select top 3 cust_id from customers)
        [/code]

        Comment

        • GROG
          New Member
          • Sep 2007
          • 34

          #5
          Originally posted by jamesd0142
          not tested, but im sure its in the right area:

          [code=sql]
          delete from customers where cust_id in (select top 3 cust_id from customers)
          [/code]

          Thanks james.. Will try..

          Comment

          • GROG
            New Member
            • Sep 2007
            • 34

            #6
            Originally posted by GROG
            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..

            Comment

            Working...