all groups > sql server programming > april 2004 >
You're in the

sql server programming

group:

Urgent - A Select statement to rank a column into quartiles


Urgent - A Select statement to rank a column into quartiles Pogas
4/13/2004 10:26:09 PM
sql server programming:
Hi, your prompt help in this will be greatly appreciated

I have an sql table below with some sample dat

Table-FunctionalConten

TrustCode OFA FC
5A1 20000 2
RR8 18598 1
RBA 36578 7
5HA 4300

TrustCode – Identity, Primary Key, char(4
OFA – numeri
FC-numeri

I want to write a select statement that will add an additional column called FCRanking, and assign the appropriate quartile(Upper quartile,,median and lower quartile) to the FC value

Ie

TrustCode OFA FC FCRankin
5A1 20000 20
RR8 18598 12
RBA 36578 76
5HA 4300 3

Hope I have made myself clear

Many thank

Poga

Re: Urgent - A Select statement to rank a column into quartiles Pogas
4/14/2004 12:36:04 AM
Stevea sample
the data provided is only a sample.I have so
many rows of FC in the region of 2000
I want a select statement that statistically group all the data into quartile
the equivalent of Excel's Quartile(Array,Quart

Where the values falls within the statistical upper quartile(1) assign 1 for that valu
Where the values falls within the statistical lower quartile(3) assign 3 for that valu
Where the values falls within the statistical midian(2) assign 2 for that valu

Hope this is clear

Thank
Poga

----- Steve Kass wrote: ----

Pogas

Can you be more specific about your definition of quartile? Given the
4 numbers 3, 76, 12, and 20, the usual statistical quartiles would put
one value in each quartile, since there are 4 distinct values. Do you
mean FC to be a percentile, in which case you want FCRanking to b

case when FC > 75 then
when FC > 50 then
when FC > 25 then
else 4 en
-- possibly with >=, depending on your definition

Steve Kas
Drew Universit

[quoted text, click to view]
Re: Urgent - A Select statement to rank a column into quartiles Steve Kass
4/14/2004 1:50:39 AM
Pogas,

Can you be more specific about your definition of quartile? Given the
4 numbers 3, 76, 12, and 20, the usual statistical quartiles would put
one value in each quartile, since there are 4 distinct values. Do you
mean FC to be a percentile, in which case you want FCRanking to be

case when FC > 75 then 1
when FC > 50 then 2
when FC > 25 then 3
else 4 end
-- possibly with >=, depending on your definition.

Steve Kass
Drew University

[quoted text, click to view]
AddThis Social Bookmark Button