Writing a range sql statement

  • How can I write a sql statement where it will return all records that are between two values

    For example I want all records to return whose id are between the number 20 and 30.

    I'm not sure how to do this.

    Any help? Thanks a lot.

  • SELECT

    *

    FROM

    #YourTableName

    WHERE

    id BETWEEN 20 AND 30

  • Thanks a lot, one last question, can this be done with currency strings? Or do I have to change one of my columns to a currency column from a varchar column

  • Looks like it... Between can do integer, date, varchar and there are more that I did not put down here....

    Stupid question here, but are you saving currency amounts as a varchar.....

    You should think of using a decimal, or money type... I like decimal as some companys go to the tenth and hundreth on the cent value $12.005

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

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