[Q]: Weird SQL
From: Neil Greene <neil_at_bMD.com>
Date: 10 Mar 1995 07:23:01 GMT
Message-ID: <3jouol$svr_at_news.starnet.net>
Date: 10 Mar 1995 07:23:01 GMT
Message-ID: <3jouol$svr_at_news.starnet.net>
I have the following tables:
SOURCE_TABLE
position varchar(2), percentage number(7,2) values: 1, 102 1, 110 1, 90 DEST_TABLE postion varchar(2), percentage number(7,2), dollar_amt number(7,2), values: 1, 100, 1000 1, 101, 1200 1, 102, 1400 1, 103, 1500 1, 104, 2000
I want to take the value of percentage from the SOURCE table and find the dollar_amt from the DEST_TABLE with the closest percentage, taking the minimum value.
102 should return $1,400 since it is an exact match. 90 should return $1,000 since 90 is not in the table and 100 is
the next lowest value.
Neil Greene
benchMark Developments, Inc.
Received on Fri Mar 10 1995 - 08:23:01 CET