mardi 14 juin 2016

Is there an equivalent of Excel's PERCENTRANK (column,value) in SQL?

Is there an equivalent of Excel's PERCENTRANK (column,value) in SQL? I think native SQL Server functions provide only percentiles from the same column, but am I missing something?

The problem is that I have two columns - A and B - and I need to use distribution of values from column A and then take values from another column and rank them against column A - how do values in B fit in distribution defined by column A (or, precisely: get CDF of column A at point defined by B).

Possible solutions:

  1. Write UDF (they don't parallelize, do they?) - can you answer how could I efficiently structure such UDF?
  2. Use SQL Server 2016 and integrate it with R (R code within SQL code)
  3. Copy data to R, perform calculations, send back to server
  4. Copy data to Excel and calculate it over there "manually", import results back to database

There are multiple columns with values and distributions I need to apply this strategy to, so I am looking for an efficient solution.

Edit - example: column A column B result 10 16 0,20 =PERCENTRANK($A1:$A4, B1) 20 35 0,83 =PERCENTRANK($A1:$A4, B2) 30 10 0,00 =PERCENTRANK($A1:$A4, B3) 40 25 0,50 =PERCENTRANK($A1:$A4, B4)

Aucun commentaire:

Enregistrer un commentaire