Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    73

    Question Unanswered: Query to pick up a particular value in particular column

    i have a table with columns a1,a2,a3,a4,a5

    a1--------- a2----------a3----------a4--------a5

    1 -----------9-----------2----------8----------103

    0.3----------0.8---------0.7--------0.6-------102

    22--------------22--------33-------33---------101



    i have to read data based on a5
    when value in a5 is 102 i have to read column number 02(i.e a2)

    when value in a5 is 103 i have to read value in column no 03 (ie column a3 and value is 2)

  2. #2
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    Based on what you have, you could use a CASE:

    Code:
    SELECT CASE A5
               WHEN 102 THEN A2
               WHEN 103 THEN A3
           END as col_value
    FROM table-name
    where...

Posting Permissions

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