Remove all values in a table expect where specified

  • Hi,

    How do I write a SQL script that will removal all values given a criteria except for certain values that I wish to keep.

    For example;

    Column1

    1

    2.23

    3.44

    5.2

    10

    11.2

    18.2

    20

    21

    So I need to remove all values <21 except for the specific values of 20,10 and 1

    Any advice warmly welcomed

  • Use the delete query with the where condition as

    Where Column1<21 and Column1 not in (20,10,1)

    Ryan
    //All our dreams can come true, if we have the courage to pursue them//

  • Ah ha! - That worked!

    Thanks so much -

    🙂

  • 😛

    Just to say ,Sumanta Roy say the same answer from my sound ;-);-) Thank you for your reply quick quick quicklyy

  • johnitech.itech (2/2/2012)


    😛

    Just to say ,Sumanta Roy say the same answer from my sound ;-);-) Thank you for your reply quick quick quicklyy

    What does that actually mean?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply