Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 4B3419FB2BC for ; Mon, 6 Aug 2007 05:57:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 72116-10 for ; Mon, 6 Aug 2007 05:57:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id C63A89FB2BA for ; Mon, 6 Aug 2007 05:57:09 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 5290131414; Mon, 6 Aug 2007 10:57:08 +0200 (MET DST) From: Kiran X-Newsgroups: pgsql.sql Subject: Best Fit SQL query statement Date: Mon, 06 Aug 2007 01:57:07 -0700 Organization: http://groups.google.com Lines: 21 Message-ID: <1186390627.045596.148460@j4g2000prf.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Complaints-To: groups-abuse@google.com User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 PROXY_SERVER Complaints-To: groups-abuse@google.com Injection-Info: j4g2000prf.googlegroups.com; posting-host=203.197.168.166; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 To: pgsql-sql@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/65 X-Sequence-Number: 29003 All, Could anyone help me in writing Best Fit SQL statement. Suppose we have table t1 with coloumn t1 (text) with following rows. 98456 98457 9845 9846 984 985 98 99 and if I query on 98456 the result must be 98456, However if I query on 98455 the result must be 9845 and If I query 9849 the result must be 984 Regards, Kiran