Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003

    Unanswered: sql statement to retrieve data

    I am trying to write an sql statement to do the following
    I have 3 columns of data that look something like this.
    A B C
    1 100 5
    2 200 8
    3 300 9
    1 100 12
    2 200 6
    3 300 11
    1 100 19
    2 200 7
    3 300 23

    I want to write a procedure that will select column "C" from the data that the user put in for column "A' and "B". I can not figure out if I should use if statements, case, or just how to compare the data. Say the user enters 1 for column A and 235 for column B. My procedure would return multiple values. I just want the value of C that resides betwen 200 and 300 of column B. Any thoughts would be greatly appreciated.

  2. #2
    Join Date
    Aug 2003
    I'm not sure if I understand what you are trying to do, but maybe this will help.

    Select c from mytable
    where a = 1 and b between 200 and 300

  3. #3
    Join Date
    Jul 2003
    This is what I have come up with
    select MIN(b) from table where
    b >= @b and a = @a

    This will return a unique b for each input. But I can figure out how to put a isnull function in to keep from going over the maximum B.

    Then I will try to put that together to get c.
    I do not want to have to put 100 betweeen 200
    200 between 300.....Too bulky.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts