select stampata_sn,numero_conto,dest_stampa,portata,categoria,prog_inser,nodo,desc_art,prezzo_un,quantita from comanda where contiene_variante='1' and ntav_comanda='25' and posizione='CONTO' and stato_record='ATTIVO' and numero_conto ="1"
union all
select stampata_sn,numero_conto,dest_stampa,portata,categoria,prog_inser,nodo,desc_art,prezzo_un,sum(quantita) as quantita from comanda where (contiene_variante !='1' or contiene_variante is null) and length(nodo)=3 and ntav_comanda='25' and posizione='CONTO' and stato_record='ATTIVO' and numero_conto ="1" group by desc_art
union all
select stampata_sn,numero_conto,dest_stampa,portata,categoria,prog_inser,nodo,desc_art,prezzo_un,quantita from comanda where length(nodo)=7 and ntav_comanda='25' and posizione='CONTO' and stato_record='ATTIVO' and numero_conto ="1" order by nodo asc;
I have this three queries.
If the first query before "union all" is the query A, and the second and third are B and C, how can i do:
(A(B ORDER BY B ASC),C) ORDER BY (A,C) ASC
I need to do:
Extract A
Extract B of A (by node) AND order alphabetical in the internal
Extract C
Then order by A (and B is an A subset),C alphabetical
Then the result will be for example
C Bitter
A Coca
B + Ice
B + Lemon
B + Orange juice
A Juice
B + Lemon
C Orange cup
C Spaghetti
instead of a random order by node, like:
C Orange cup
A Juice
B + Lemon
C Bitter
A Coca
B + Orange juice
B + Ice
B + Lemon
C Spaghetti
I hope to been clear.
Thank you.
Aucun commentaire:
Enregistrer un commentaire