On Tue, 17 May 2016 11:09:53 +1000
"dandl" <david at andl.org> wrote:
> > I'll invent here and now to replace LIMIT: nth().
>
> The issue is find the "top N". This does not solve the problem.
nth() does find "top N". For any query, nth(c, N) returns N rows. It
also exposes the arbitrariness of LIMIT. To use nth() correctly for
Simon's data
select * from T as out where exists (
select 1 from T
where out.first = first and out.second = second
group by second
having nth(second, 2) <= out.second
);
produces 4 rows. Deterministically. Unambiguously.
The "problem" is to produce 3 rows where, relationally, the only
answers have 2 or 4 rows. There is no right answer to the problem
because there is no answer to the problem.
--jkl