Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> dynamically determining the field to select
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;
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
![]() |
![]() |