Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 3D8BF9FB2B8 for ; Thu, 1 Feb 2007 17:16:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 84275-03 for ; Thu, 1 Feb 2007 17:16:08 -0400 (AST) X-Greylist: delayed 00:23:11.182821 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 2D7169FB2ED for ; Thu, 1 Feb 2007 17:16:08 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mx1.ucdavis.edu (mx1.ucdavis.edu [128.120.32.31]) by svr4.postgresql.org (Postfix) with ESMTP id 856A65AF91F for ; Thu, 1 Feb 2007 20:52:56 +0000 (GMT) Received: from [128.120.136.244] ([128.120.136.244]) (authenticated bits=0) by mx1.ucdavis.edu (8.13.7/8.13.1/it-defang-5.4.0) with ESMTP id l11Kqmxt023077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 1 Feb 2007 12:52:49 -0800 (PST) Message-ID: <45C253FC.2040002@ucdavis.edu> Date: Thu, 01 Feb 2007 12:56:28 -0800 From: Wei ZOU User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 Newsgroups: gmane.comp.db.postgresql.sql To: pgsql-sql@postgresql.org Subject: Search a range of cases/records X-Enigmail-Version: 0.94.1.1 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.57 on 128.120.32.31 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50 X-Spam-Level: X-Archive-Number: 200702/39 X-Sequence-Number: 27373 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Greetings: I have a dataset of two columns: price amount 99.5 10000 99.7 8000 100 3000 100.1 1000 100.5 500 100.8 1500 105 2000 200 100 etc I have to write a SQL query on how many price tags are within [price+-1] such as 98.5 to 100.5, 100+-1,etc for each records. Here I know the price tags counts are 5 for 99.5-100.5, 5 for 99.7-100.7, 6 for 99-101, etc How should I do for all of the records? Thanks in advance. Wei -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFwlP8llCA8yArcwwRAiFsAJ0Vmbkj5BRjRJ6zokrHdYZEgpHujACgjbiL bcw0Lcpcfdt74CXkBNaWAqQ= =pTSo -----END PGP SIGNATURE-----