You are here: Re: SQL a range in the all dataset « MsSQL Server « IT news, forums, messages
Re: SQL a range in the all dataset

Posted by Steve on 02/02/07 01:33

On Feb 1, 4:59 pm, Wei ZOU <w...@ucdavis.edu> wrote:
> -----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
>
> iD8DBQFFwozpllCA8yArcwwRAlzhAJ0dXvJeN8r5tCMwbikokrI9qXok0ACfcWA9
> 4WJ90KIbVaXu6aznolw8CDE=
> =K+6d
> -----END PGP SIGNATURE-----

SELECT COUNT(*)
FROM MyTable
WHERE price BETWEEN startPrice AND endPrice;

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация