Skip to main content
Tweeted twitter.com/#!/StackDBAs/status/415657693534507008
trim noise, minor edits, adapt title, add tags
Source Link
Erwin Brandstetter
  • 182.1k
  • 28
  • 457
  • 620

PostgreSQL- Calculating Select row at the nth percentile row

This is my first encounter to PostgreSQL.

I have two tables, table1table1 and table2table2. Let Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows.

The query is:

    Select table1.date,(table2.latency - table1.latency) as ans from table1, table2  
where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say iI need to find 90%,99% 99% and 99.9% percentile row from the data.

I need to display the data in somewhat thisa form like this:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015
    05-12-2000 |    99.9       | 0.012

This is my first encounter to PostgreSQL. I am confused as to how should I proceed.

I was having a look at PERCENT_RANK()PERCENT_RANK() function.

  Please guide me in the correct direction.

PostgreSQL- Calculating the nth percentile row

This is my first encounter to PostgreSQL.

I have two tables, table1 and table2. Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows.

The query is

    Select table1.date,(table2.latency - table1.latency) as ans from table1, table2 where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say i need to find 90%,99% and 99.9% percentile row from the data.

I need to display the data in somewhat this form:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015
    05-12-2000 |    99.9       | 0.012

I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function.

  Please guide me in the correct direction.

Select row at the nth percentile

I have two tables, table1 and table2. Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows:

Select table1.date,(table2.latency - table1.latency) as ans from table1, table2 
where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say I need to find 90%, 99% and 99.9% percentile row from the data.

I need to display the data in a form like this:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015
    05-12-2000 |    99.9       | 0.012

This is my first encounter to PostgreSQL. I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function. Please guide me in the correct direction.

added 363 characters in body
Source Link
D3XT3R
  • 83
  • 1
  • 6

This is my first encounter to PostgreSQL.

I have two tables, table1 and table2. Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows.

The query is

    Select table1.date,(table2.latency - table1.latency) as ans from table1, table2 where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say i need to find 90%,99% and 99.9% percentile row from the data.

I need to display the data in somewhat this form:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015
    05-12-2000 |    99.9       | 0.012

I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function.

Please guide me in the correct direction.

This is my first encounter to PostgreSQL.

I have two tables, table1 and table2. Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows.

The query is

    Select table1.date,(table2.latency - table1.latency) as ans from table1, table2 where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say i need to find 90%,99% and 99.9% percentile row from the data.

I need to display the data in somewhat this form:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015

I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function.

Please guide me in the correct direction.

This is my first encounter to PostgreSQL.

I have two tables, table1 and table2. Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows.

The query is

    Select table1.date,(table2.latency - table1.latency) as ans from table1, table2 where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say i need to find 90%,99% and 99.9% percentile row from the data.

I need to display the data in somewhat this form:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015
    05-12-2000 |    99.9       | 0.012

I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function.

Please guide me in the correct direction.

added 363 characters in body
Source Link
D3XT3R
  • 83
  • 1
  • 6

This is my first encounter to PostgreSQL.

I have two tables, table1 and table2. Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows. I

The query is

    Select table1.date,(table2.latency - table1.latency) as ans from table1, table2 where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say i need to find 90%,99% and 99.9% percentile row from the data.

I need to display the data in somewhat this form:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015

I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function.

Please guide me in the correct direction.

This is my first encounter to PostgreSQL.

I have two tables, table1 and table2.

I have a simple query that performs a join on the two tables and returns a set of rows. I need to find the nth percentile row from the returned set of rows, lets say i need to find 90%,99% and 99.9% percentile row from the data.

I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function.

Please guide me in the correct direction.

This is my first encounter to PostgreSQL.

I have two tables, table1 and table2. Let the two tables contain date, id and latency column.

I have a simple query that performs a join on the two tables and returns a set of rows.

The query is

    Select table1.date,(table2.latency - table1.latency) as ans from table1, table2 where table1.id = table2.id order by ans;

I need to find the nth percentile row from the returned set of rows, lets say i need to find 90%,99% and 99.9% percentile row from the data.

I need to display the data in somewhat this form:

    date       |   percentile  | ans
    01-12-1995 |    90         | 0.001563
    02-12-1999 |    99         | 0.0015

I am confused as to how should I proceed.

I was having a look at PERCENT_RANK() function.

Please guide me in the correct direction.

Source Link
D3XT3R
  • 83
  • 1
  • 6
Loading