Search a range of cases/records

From: Wei ZOU <wzou(at)ucdavis(dot)edu>
To: pgsql-sql(at)postgresql(dot)org
Subject: Search a range of cases/records
Date: 2007-02-01 20:56:28
Message-ID: 45C253FC.2040002@ucdavis.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

-----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-----

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Chris Browne 2007-02-01 22:45:06 Re: Index Anding
Previous Message André José Guergolet 2007-02-01 19:09:22 Insert Data and autonumeric field