Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating deciles in Sybase

0 views
Skip to first unread message

Mike Marcal

unread,
Jul 5, 1995, 3:00:00 AM7/5/95
to

Does anyone have any ideas on how to solve the following problem in
Sybase's Transact-SQL?

I have a table A( id int, val double ) that was derived from a timeseries
table. Thus each id has an associated set of values val. The dates
associated with each val for a given id is immaterial for the purpose of
this problem. Table A contains many different id's. There is no relationships
between the individual id's (i.e. you cannot derive from another).

The problem is to find the lower decile for each id in Table A.
So suppose for each id, we sort the corresponding vals as:

val[1] <= val[2] <= val[3] <= ... <= val[N]

then the lower decile is val[floor( (N * 0.1) + 1 )].

It is easy to see that if I could "label" the rows with their indexes 1....N,
then the solution is trivial. I think this can be done under System 10 with the
IDENTITY column concept, but I am using version 4.9.x.

Thanks in advance

Michael Marcal
e-mail: marc...@gs.com
--
Michael A. Marcal (marc...@gs.com)
Goldman, Sachs & Co.
85 Broad St.
New York, NY 10004
(212) 902-8496

0 new messages