Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> dynamically determining the field to select

dynamically determining the field to select

From: hastenthunder <hastenthunder_at_hotmail.com>
Date: Wed, 21 Jul 2004 12:51:37 -0400
Message-ID: <taxLc.727$Ny6.1739@mencken.net.nih.gov>


Hi SQL Masters,

I'm trying to perform a rather simple query, but the field I'm selecting from the table can only be determined at run time, basing on the value of some other field in the same table. The logic is like:

    IF (year_of_sales < 1995) THEN

        SELECT fieldA
        FROM myTable;
    ELSE IF (year_of_sales >1995 and year_of_sales< 1998) THEN
        SELECT fieldB
        FROM myTable;
    ELSE
        SELECT fieldC
        FROM myTable;

    END IF; The table looks like:

    Create tabe myTable (year_of_sales number(4),

                                           fieldA varchar2(5),
                                           fieldB varcahr2(5),
                                           fieldC varchar2(5));


Can someone help me to put the above query into a single SQL statement? Is it possible?

Thanks a lot. Received on Wed Jul 21 2004 - 11:51:37 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US