Note that there are some explanatory texts on larger screens.

plurals
  1. USmiyasudokoro
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. COThe correct way to test my query is to create a situation where you know for sure what values should be Pct10 and what ones should be Pct90. So, do your create table again, but instead of using rand(), insert ten of A, five of B, and one of C for each date. The query should then return Pct10 = C and Pct90 = A for each date. Build it on sqlfiddle so we can take a look. I am on vacation now so I don't have access to my previous tests.
      singulars
    2. COAnother way of thinking about it is, if A and B occur the same number of times, then they will have the same Abs90. That means they will both be selected by MIN(Abs90) = Abs90 in the subquery x. Because I did not specify an order for any of the subqueries, the database naturally picks the first one it comes to, which may or may not be A. And this same tie can happen again in Abs10 = MIN(Abs10) because A and B still have an equal number of values.
      singulars
    3. COThe way it works is, this is figuring the percentile of "how many times Value X appears." If you have values A-Z, and each of them appears once, then Pct10 will likely be the same as Pct90, because all of the values are tied for Pct10 and Pct90, so the one that comes out gets chosen out of the same tie twice, based on how the database naturally orders things. If X appears twice and all the other letters A-Z appear once, then X will be Pct90 but the rest will be tied for Pct10 and one of the things in that tie will come out the same as I described before.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload