SELECT question

From: Chuck McMacken <chuck_at_pdm4340.arh.cdc.com>
Date: Fri, 15 Apr 1994 14:59:37 GMT
Message-ID: <CoB2zF.5ur_at_cdsmail.cdc.com>


I have a SELECT problem I've been unable to resolve and would greatly appreciate your help.

The simplified table is described as var1 number(4,3) and contains values in the range 9.999 to -9.999. I need to select the value of var1 which is closest to 1.000. I'm able to use the ABS and MIN functions to locate the row containing target value and the delta, but I haven't been able to retrieve the actual content of var1 from the target row.

Given a list for var1 of:

   2.123
   1.014
   0.837
   0.001

   SELECT min(abs(1.000 - var1) from tab;

   returns a delta of .013 for the 0.837 entry which is the row I'm seeking    in the example.

Unfortunately, I haven't been able to find a way to utilize the result of this select or sub-select/self-join to retrieve the 0.837 value. Any replies can either be e-mailed or posted.

Thanks

Chuck


Chuck McMacken      ARH282                              Phone: (612) 482-5578
Control Data Systems, Inc.                    
Suite 880                                               Fax:   (612) 482-4393
7760 France Avenue South                          
Bloomington MN, 55435                             email: C.N.Mcmacken_at_cdc.com

_____________________________________________________________________________
Received on Fri Apr 15 1994 - 16:59:37 CEST

Original text of this message