i just cant find a way to get this query to work.
what i want is basically a result graph extracted from a database, and i want this graph to be reduce to 500 row (the un-reduced tables have several 10k of rows)
sum(hp.totalProfit) over (order by h.startTime) as totalProfit,
row_number() over () as rn,
INNER JOIN h ON (h.id = hp.handId)
WHERE hp.playerid in (11)
ORDER BY h.startTime
where (rn % DIVISOR)<=1;
DIVISOR should be [Count of rows of inner select statement OR max of (rn) ] / 500
i tested it manually (calculating the DIVISOR value by hand for each pl.id) and the result i get is always something between 495-500 rows, which is fine.
i would like to avoid using statistical functions as its not necessary. but havent found any way to get number of rows from the inner SELECT into the where of the outer select.
your help is much appreciated