View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 07:48 PM
Indraneel Sheorey
 
Posts: n/a
Default Creating Deciles

Hello,

I want to set up a query in SQL Server that is "grouped by" a variable
PRICE. Since PRICE takes on continuous decimal values, I want to
create deciles based on this variable and then display the average
price in each decile. As background, PRICE is a calculated quantity:
I divide a table field SLS_DLRS by a field SLS_UNTS to get it. I also
want to include an average SLS_UNTS for each decile.

So essentially, I want the result to be something like:
DECILE AVG_PRICE AVG_SLS_UNTS
1 0.50 5.2
2 1.50 4.7
.... ... ...
10 9.50 1.1

Is there a way to do this in an SQL statement?

Thanks in advance,
Indraneel
Reply With Quote