On 31 Jul 2015, at 1:26pm, John McKown <john.archie.mckown at gmail.com> wrote:

> WITH summary AS
>   ( SELECT var, count(var) as total FROM table GROUP BY key )
> SELECT a.var, 100*a.var/b.total as percentage FROM table AS a
> INNER JOIN summary AS b ON a.key=b.key
> ORDER BY key

Thank you at last for an example of non-recursive CTE being useful in the real 
world.

I am noting an overlap with the things SQLite users have been using sub-SELECTs 
for.

Simon.

Reply via email to