Questions tagged [percentile-cont]

21 questions
5
votes
3 answers

How can I include a PERCENTILE_CONT column within a select statement without generating an error about the ORDER BY clause or aggregate function?

I have a need to generate a particular report from some data and I am having a great deal of trouble figuring out the proper usage of PERCENTILE_CONT to provide the results I need. I would like to include a column in my query result which shows…
user3908134
  • 81
  • 1
  • 7
4
votes
2 answers

Percentiles in MariaDB

I'm trying to find the 25th and 75th percentiles in MariaDB 10.4.11, according to https://mariadb.com/kb/en/percentile_cont/ I believe the below code is the correct way to do it, however it returns the same result for each calculation? select name,…
5318008
  • 77
  • 5
3
votes
1 answer

How to use percentile_conts with multiple quantiles in Postgres

I currently have a query that works like so: select AVG(t2 - t1) as delay, percentile_cont(0.25) within group (order by (t2 - t1)) as q25, percentile_cont(0.5) within group (order by (t2 - t1)) as median, percentile_cont(0.75)…
Mittenchops
  • 18,633
  • 33
  • 128
  • 246
1
vote
2 answers

percentile_cont with aggregate Function

I'm using SQL Server 2012 and trying to calculate some aggregate functions and percentiles on a data set with two columns (id and time). In my research I found some solutions, but they don't work for me (maybe it's because of my outdated SQL…
1
vote
1 answer

Find median of dates in PostgreSQL

I was wondering if there is a way to find the 'median' date in PostgreSQL. The goal is to obtain, according to the median, the date that is in the middle of all the dates. I tried following modified median function: select percentile_cont(0.5)…
Albin
  • 822
  • 1
  • 7
  • 25
1
vote
0 answers

Calling T-SQL's "PERCENTIlE_CONT" directly from EntityFramework Core

This SO question describes how to call DatePart function using EntityFramework: I wonder if I can provide a similar binding for PERCENTILE_CONT. Or maybe the only way to use PERCENTILE_CONT via EntityFramework is to have a stored procedure and call…
1
vote
0 answers

Multiple PARTITION BY ... OVER the same column in T-SQL

I found the following query in a book on T-SQL SELECT round(SUM(TotalDue),1) AS Sales, LastName, FirstName, SalesPersonId, AccountNumber, PERCENTILE_CONT(0.4) WITHIN GROUP (ORDER BY round(SUM(TotalDue),1)) OVER(PARTITION BY AccountNumber) AS…
LA.27
  • 1,888
  • 19
  • 35
1
vote
0 answers

How can I convert the Percentile_Disc in SQL to Spark Sql

At work we're moving from Teradata to Spark SQL (Hadoop Cluster), so I need to convert many of my scripts. Here is my original SQL script, and I am trying to get the 60th percentile of the cust. satisfaction rating (i.e. top 40% of performers) for…
0
votes
0 answers

Multiple Percentile_Cont() calls with different order by's in AWS Redshift

I am trying to call Percentile_Cont() within group (order by column_name) multiple times with each one having a different order by column_name AWS Redshift has the following documentation forbidding this: If a statement includes multiple calls to…
0
votes
1 answer

How to use PERCENTILE_CONT in GROUP BY query?

I have a table named TabA with the following columns, Id Currency Value Institution Expected Results: Id Currency Cnt Median(Value) Institution I am getting the values except Median(Value) using the below query, SELECT Id, Currency,Count(*)…
aka baka
  • 213
  • 2
  • 10
0
votes
1 answer

I want ntile(3) within ntile(3) as in subdivision within division by ntile()

I want to create a ntile(3) within an ntile(3). I have the following table: Customer Total_amt Digital_amt 1  100 45 2 200 150 3 150 23 4 300 100 5 350 350 6 112 10 7 312 15 8 260 160 9 232 150 10 190 132 I want to have…
0
votes
0 answers

Calculating Percentile on large SQL tables

I have a large SQL table with 100+ million records in SQL Server as follows: +-----------+----------+----------+----------+----------+ |CustomerID |TransDate |Category | Num_Trans |Sum_Trans…
0
votes
1 answer

PostgreSQL want to round percentile_cont

I am computing a range of values in PostgreSQL, and I want to round some of them to 2 decimal places. when I do round the average it works round(avg(rate), 2) as avg_rate. when I round the median round(percentile_cont(0.5) within group (order by…
gjc
  • 29
  • 3
0
votes
1 answer

How to calculate the number of rows (& their percentage) that fall below the 10th percentile of column in SQL?

I have a column with numbers. I already calculated the percentiles using percentile_cont. How can I sum up/count all the rows (& calculate their %) that fall below, e.g. the 25th percentile?
Kim Ida
  • 5
  • 3
0
votes
1 answer

calculate percentile and use case when in sql

I have a data set Cashback table user | order_amount -------+------------ raj | 200 rahul | 400 sameer | 244 amit | 654 arif | 563 raj | 245 rahul | 453 amit | 534 arif | 634 raj | 245 amit | 235 rahul | 345 arif | 632 I…
user16795956
1
2