On Sat, Jul 5, 2014 at 8:12 AM, Edson Richter wrote:
> Thanks!
>
> I'll investigate (explain) performance for both versions.
also be advised that in most cases when you use SQL 'UNION' you really
should be using 'UNION ALL'. It's a very common mistake:
UNION: form proper set union, combine set
Thanks!I'll investigate (explain) performance for both versions. Atenciosamente,Edson Richter -- Mensagem original --De: David Johnston Data: 04/07/2014 21h20Para: Edson Richter;Cc:pgsql-general@postgresql.org;Assunto:Re: Re : [GENERAL] Query "top 10 and others"> with
>
> > with QRY as (select C1.country, C1.state, sum(C1.population)
> > from places C1
> > group by 1, 2
> >order by 3 DESC
> > limit 10)
> >
> > select * from QRY
> > union
> > select 'others' as "country", '' as "state", sum(population)
> > from places
> > where not exists (select 1 f
Would you please provide an example, even hypothetical? Atenciosamente,Edson Richter -- Mensagem original --De: David G Johnston Data: 04/07/2014 19h22Para: pgsql-general@postgresql.org;Assunto:Re: [GENERAL] Query "top 10 and others"Edson Richter wrote
> I would like to cons
Edson Richter wrote
> I would like to construct a query, to be used in graphics (Pie Chart, to
> be more precise), and to avoid having 500 slices, I would like to make a
> query that returns the top ten, and then all the rest summed.
>
> I know I can do it by using some repetition, like:
>
> a) A
I would like to construct a query, to be used in graphics (Pie Chart, to be
more precise), and to avoid having 500 slices, I would like to make a query
that returns the top ten, and then all the rest summed.
I know I can do it by using some repetition, like:
a) Assume "places" table with popula