pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: v.campanella47@gmail.com
Subject: BUG #15882: Select .... UNION ALL
Date: Tue, 02 Jul 2019 08:28:18 +0000
Message-ID: <15882-302159bb3eaa957e@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15882
Logged by:          Vincenzo Campanella
Email address:      v.campanella47@gmail.com
PostgreSQL version: 11.4
Operating system:   windows 10 build 1903
Description:        

cSelect = "select 1 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-01-01' and data <= '" + cAnno +
"-01-31' and T_MPR='M' " +
									"union all " +
									"select 2 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-02-01' and data <= '" + cAnno +
"-02-" + MyFunc.Ultimo_Giorno_Mese(2, Converti.ToInt32(cAnno)) + "' and
T_MPR='M' " +
									"union all " +
									"select 3 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-03-01' and data <= '" + cAnno +
"-03-31' and T_MPR='M' " +
									"union all " +
									"select 4 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-04-01' and data <= '" + cAnno +
"-04-30' and T_MPR='M' " +
									"union all " +
									"select 5 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-05-01' and data <= '" + cAnno +
"-05-31' and T_MPR='M' " +
									"union all " +
									"select 6 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-06-01' and data <= '" + cAnno +
"-06-30' and T_MPR='M' " +
									"union all " +
									"select 7 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-07-01' and data <= '" + cAnno +
"-07-31' and T_MPR='M' " +
									"union all " +
									"select 8 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-08-01' and data <= '" + cAnno +
"-08-31' and T_MPR='M' " +
									"union all " +
									"select 9 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-09-01' and data <= '" + cAnno +
"-09-30' and T_MPR='M' " +
									"union all " +
									"select 10 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-10-01' and data <= '" + cAnno +
"-10-31' and T_MPR='M' " +
									"union all " +
									"select 11 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-11-01' and data <= '" + cAnno +
"-11-30' and T_MPR='M' " +
									"union all " +
									"select 12 as prog,sum(imp_asl) as Importo_Asl
,Count(Arc_Ref.n_Rif) as nRicette,sum(n_Pre) as nPrelievi " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-12-01' and data <= '" + cAnno +
"-12-31' and T_MPR='M' " +
									"union all " +
									"select 13 as prog,sum(imp_asl) as Importo_Asl,Count(Arc_Ref.n_Rif)
as nRicette,sum(n_Pre) as nPrelievi  " +
									"from " + MyFunc.cSchema + "Arc_Ref " +
									"where data >= '" + cAnno + "-01-01' and data <= '" + cAnno +
"-12-31' and T_MPR='M' ";
This produces an unordered but random table.
I put the prog field and then make the ascending order on this field.
In previous versions the order was in the typed sequence.
Greetings
Enzo Campanella
(v.campanella@tin.it)



view thread (3+ messages)  latest in thread

Message-ID: <15882-302159bb3eaa957e@postgresql.org>
Permalink:  ../15882-302159bb3eaa957e@postgresql.org/
Also on:    postgresql.org/message-id/15882-302159bb3eaa957e@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, v.campanella47@gmail.com
  Subject: Re: BUG #15882: Select .... UNION ALL
  In-Reply-To: <15882-302159bb3eaa957e@postgresql.org>
  References: <15882-302159bb3eaa957e@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox