Agregar union sin alterar el orden de los demas

Buen día a todos!!
Espero estén pasando un excelente día, tengo un problema con un query que necesito sacar.
Lo que pasa es que estoy intentando agregar 2 union a una query que hice vista para poder poner el total general por meta y real pero las necesito poner hasta abajo y sin alterar el orden del acomodo de la query principal.
Aquí les muestro:
Cuando ejecuto la vista principal donde tengo mi query ordenada por ‘Agente’ y por ‘U/M’ y así me da el resultado que quiero en cuanto al ordenamiento:

Pero cuando le agrego los union para agregarle el total general por Meta y Real ya no sale en orden la vista donde tengo mi query principal:

alguien sabe como agregar union sin que altere el orden de los demás union?
o alguna manera de poder poner el total general por Meta y Real hasta abajo de mi query pero siguiendo el orden de Agentes y U/M.

Les dejo mis querys:

QUERY DE LA VISTA DEL QUERY PRINCIPAL:

CREATE VIEW "ASC_MEX"."Ventas_agente_mensual_2019" ( "Agentes",
	 "U/M",
	 "Enero",
	 "Febrero",
	 "Marzo",
	 "Abril",
	 "Mayo",
	 "Junio",
	 "Julio",
	 "Agosto",
	 "Septiembre",
	 "Octubre",
	 "Noviembre",
	 "Diciembre",
	 "Total" ) AS ((Select
	 t0."Ejecutivo" as "Agentes",
	 'Meta' as "U/M",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		then '0' when t0."Ejecutivo" = 'Rocio Bárcenas' 
		then '0' when t0."Ejecutivo" = 'Marisol Lizaola' 
		then '0' when t0."Ejecutivo" = 'Tania Amezquita' 
		then '0' when t0."Ejecutivo" = 'José González' 
		then '0' when t0."Ejecutivo" = 'Miguel Garcia' 
		then '0' when t0."Ejecutivo" = 'Gustavo Esparza' 
		then '0' when t0."Ejecutivo" = 'Alejandro Aguirre' 
		then '0' when t0."Ejecutivo" = 'Félix Ibarra' 
		then '0' when t0."Ejecutivo" = 'Aramis Eduardo Ibarra Garcia' 
		then '0' when t0."Ejecutivo" = 'Antonio Martinez' 
		then '0' when t0."Ejecutivo" = 'Enna Quintero' 
		then '0' when t0."Ejecutivo" = 'José Guadalupe Gonzalez Neri' 
		then '0' when t0."Ejecutivo" = 'Maria de los Angeles Antonio' 
		then '0' when t0."Ejecutivo" = 'Raymundo Lara' 
		then '0' when t0."Ejecutivo" = 'Cabrera Velazquez Luis Alberto' 
		then '0' when t0."Ejecutivo" = 'Delgadillo Lievanos Karem Alejandra' 
		then '0' when t0."Ejecutivo" = 'Flores Escamilla Eduardo' 
		then '0' when t0."Ejecutivo" = 'Lizaola Rojas Graciela Marisol' 
		then '0' when t0."Ejecutivo" = 'Alejandra Canales' 
		then '0' when t0."Ejecutivo" = 'Josue Salcedo' 
		then '0' when t0."Ejecutivo" = 'German Luna' 
		then '0' when t0."Ejecutivo" = 'Abraham Granados Castolo' 
		then '0' when t0."Ejecutivo" = 'Ariel Macías' 
		then '0' when t0."Ejecutivo" = 'Enrique Soriano' 
		then '0' when t0."Ejecutivo" = 'Web Portal' 
		then '0' when t0."Ejecutivo" = 'Salvador Aguilar' 
		then '0' when t0."Ejecutivo" = 'Antonio Giron' 
		then '0' when t0."Ejecutivo" = 'Garantías' 
		then '0' 
		end as "Enero",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		then '0' when t0."Ejecutivo" = 'Rocio Bárcenas' 
		then '0' when t0."Ejecutivo" = 'Marisol Lizaola' 
		then '0' when t0."Ejecutivo" = 'Tania Amezquita' 
		then '0' when t0."Ejecutivo" = 'José González' 
		then '0' when t0."Ejecutivo" = 'Miguel Garcia' 
		then '0' when t0."Ejecutivo" = 'Gustavo Esparza' 
		then '0' when t0."Ejecutivo" = 'Alejandro Aguirre' 
		then '0' when t0."Ejecutivo" = 'Félix Ibarra' 
		end as "Febrero",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		end as "Marzo",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 

		end as "Abril",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' 

		end as "Mayo",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' 

		end as "Junio",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		then '0' when t0."Ejecutivo" = 'Rocio Bárcenas' 
		then '0' when t0."Ejecutivo" = 'Marisol Lizaola' 
		then '0' when t0."Ejecutivo" = 'Tania Amezquita' 
		then '0' when t0."Ejecutivo" = 'José González' 
		then '0' when t0."Ejecutivo" = 'Miguel Garcia' 
		then '0' when t0."Ejecutivo" = 'Gustavo Esparza' 
		then '0' when t0."Ejecutivo" = 'Alejandro Aguirre' 
		then '0' when t0."Ejecutivo" = 'Félix Ibarra' 
		then '0' when t0."Ejecutivo" = 'Aramis Eduardo Ibarra Garcia' 
		then '0' when t0."Ejecutivo" = 'Antonio Martinez' 
		then '0' when t0."Ejecutivo" = 'Enna Quintero' 
		then '0' when t0."Ejecutivo" = 'José Guadalupe Gonzalez Neri' 
		then '0' when t0."Ejecutivo" = 'Maria de los Angeles Antonio' 
		then '0' when t0."Ejecutivo" = 'Raymundo Lara' 
		then '0' when t0."Ejecutivo" = 'Cabrera Velazquez Luis Alberto' 
		then '0' when t0."Ejecutivo" = 'Delgadillo Lievanos Karem Alejandra' 
		then '0' when t0."Ejecutivo" = 'Flores Escamilla Eduardo' 
		then '0' when t0."Ejecutivo" = 'Lizaola Rojas Graciela Marisol' 
		then '0' when t0."Ejecutivo" = 'Alejandra Canales' 
		then '0' 
		
		end as "Julio",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		then '0' when t0."Ejecutivo" = 'Rocio Bárcenas' 
		then '0' when t0."Ejecutivo" = 'Marisol Lizaola' 
		then '0' when t0."Ejecutivo" = 'Tania Amezquita' 
		then '0' when t0."Ejecutivo" = 'José González' 
		then '0' when t0."Ejecutivo" = 'Miguel Garcia' 
		then '0' when t0."Ejecutivo" = 'Gustavo Esparza' 
		then '0' when t0."Ejecutivo" = 'Alejandro Aguirre' 
		then '0' when t0."Ejecutivo" = 'Félix Ibarra' 
		then '0' when t0."Ejecutivo" = 'Aramis Eduardo Ibarra Garcia' 
		then '0' when t0."Ejecutivo" = 'Antonio Martinez' 
		then '0' when t0."Ejecutivo" = 'Enna Quintero' 
		then '0' when t0."Ejecutivo" = 'José Guadalupe Gonzalez Neri' 
		then '0' when t0."Ejecutivo" = 'Maria de los Angeles Antonio' 
		then '0' when t0."Ejecutivo" = 'Raymundo Lara' 
		then '0' when t0."Ejecutivo" = 'Cabrera Velazquez Luis Alberto' 
		then '0' when t0."Ejecutivo" = 'Delgadillo Lievanos Karem Alejandra' 
		then '0' when t0."Ejecutivo" = 'Flores Escamilla Eduardo' 
		then '0' when t0."Ejecutivo" = 'Lizaola Rojas Graciela Marisol' 
		then '0' when t0."Ejecutivo" = 'Alejandra Canales' 
		then '0' when t0."Ejecutivo" = 'Josue Salcedo' 
		then '0' when t0."Ejecutivo" = 'German Luna' 
		then '0' when t0."Ejecutivo" = 'Abraham Granados Castolo' 
		then '0' when t0."Ejecutivo" = 'Ariel Macías' 
		then '0' when t0."Ejecutivo" = 'Enrique Soriano' 
		then '0' when t0."Ejecutivo" = 'Web Portal' 
		then '0' when t0."Ejecutivo" = 'Salvador Aguilar' 
		then '0' when t0."Ejecutivo" = 'Antonio Giron' 
		then '0' when t0."Ejecutivo" = 'Garantías' 
		then '0' 
		end as "Agosto",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		then '0' when t0."Ejecutivo" = 'Rocio Bárcenas' 
		then '0' when t0."Ejecutivo" = 'Marisol Lizaola' 
		then '0' when t0."Ejecutivo" = 'Tania Amezquita' 
		then '0' when t0."Ejecutivo" = 'José González' 
		then '0' when t0."Ejecutivo" = 'Miguel Garcia' 
		then '0' when t0."Ejecutivo" = 'Gustavo Esparza' 
		then '0' when t0."Ejecutivo" = 'Alejandro Aguirre' 
		then '0' when t0."Ejecutivo" = 'Félix Ibarra' 
		then '0' when t0."Ejecutivo" = 'Aramis Eduardo Ibarra Garcia' 
		then '0' when t0."Ejecutivo" = 'Antonio Martinez' 
		then '0' when t0."Ejecutivo" = 'Enna Quintero' 
		then '0' when t0."Ejecutivo" = 'José Guadalupe Gonzalez Neri' 
		then '0' when t0."Ejecutivo" = 'Maria de los Angeles Antonio' 
		then '0' when t0."Ejecutivo" = 'Raymundo Lara' 
		then '0' when t0."Ejecutivo" = 'Cabrera Velazquez Luis Alberto' 
		then '0' when t0."Ejecutivo" = 'Delgadillo Lievanos Karem Alejandra' 
		then '0' when t0."Ejecutivo" = 'Flores Escamilla Eduardo' 
		then '0' when t0."Ejecutivo" = 'Lizaola Rojas Graciela Marisol' 
		then '0' when t0."Ejecutivo" = 'Alejandra Canales' 
		then '0' when t0."Ejecutivo" = 'Josue Salcedo' 
		then '0' when t0."Ejecutivo" = 'German Luna' 
		then '0' when t0."Ejecutivo" = 'Abraham Granados Castolo' 
		then '0' when t0."Ejecutivo" = 'Ariel Macías' 
		then '0' when t0."Ejecutivo" = 'Enrique Soriano' 
		then '0' when t0."Ejecutivo" = 'Web Portal' 
		then '0' when t0."Ejecutivo" = 'Salvador Aguilar' 
		then '0' when t0."Ejecutivo" = 'Antonio Giron' 
		then '0' when t0."Ejecutivo" = 'Garantías' 
		then '0' 
		end as "Septiembre",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		then '0' when t0."Ejecutivo" = 'Rocio Bárcenas' 
		then '0' when t0."Ejecutivo" = 'Marisol Lizaola' 
		then '0' when t0."Ejecutivo" = 'Tania Amezquita' 
		then '0' when t0."Ejecutivo" = 'José González' 
		then '0' when t0."Ejecutivo" = 'Miguel Garcia' 
		then '0' when t0."Ejecutivo" = 'Gustavo Esparza' 
		then '0' when t0."Ejecutivo" = 'Alejandro Aguirre' 
		then '0' when t0."Ejecutivo" = 'Félix Ibarra' 
		then '0' when t0."Ejecutivo" = 'Aramis Eduardo Ibarra Garcia' 
		then '0' when t0."Ejecutivo" = 'Antonio Martinez' 
		then '0' when t0."Ejecutivo" = 'Enna Quintero' 
		then '0' when t0."Ejecutivo" = 'José Guadalupe Gonzalez Neri' 
		then '0' when t0."Ejecutivo" = 'Maria de los Angeles Antonio' 
		then '0' when t0."Ejecutivo" = 'Raymundo Lara' 
		then '0' when t0."Ejecutivo" = 'Cabrera Velazquez Luis Alberto' 
		then '0' when t0."Ejecutivo" = 'Delgadillo Lievanos Karem Alejandra' 
		then '0' when t0."Ejecutivo" = 'Flores Escamilla Eduardo' 
		then '0' when t0."Ejecutivo" = 'Lizaola Rojas Graciela Marisol' 
		then '0' when t0."Ejecutivo" = 'Alejandra Canales' 
		then '0' when t0."Ejecutivo" = 'Josue Salcedo' 
		then '0' when t0."Ejecutivo" = 'German Luna' 
		then '0' when t0."Ejecutivo" = 'Abraham Granados Castolo' 
		then '0' when t0."Ejecutivo" = 'Ariel Macías' 
		then '0' when t0."Ejecutivo" = 'Enrique Soriano' 
		then '0' when t0."Ejecutivo" = 'Web Portal' 
		then '0' when t0."Ejecutivo" = 'Salvador Aguilar' 
		then '0' when t0."Ejecutivo" = 'Antonio Giron' 
		then '0' when t0."Ejecutivo" = 'Garantías' 
		then '0' 
		end as "Octubre",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		then '0' when t0."Ejecutivo" = 'Rocio Bárcenas' 
		then '0' when t0."Ejecutivo" = 'Marisol Lizaola' 
		then '0' when t0."Ejecutivo" = 'Tania Amezquita' 
		then '0' when t0."Ejecutivo" = 'José González' 
		then '0' when t0."Ejecutivo" = 'Miguel Garcia' 
		then '0' when t0."Ejecutivo" = 'Gustavo Esparza' 
		then '0' when t0."Ejecutivo" = 'Alejandro Aguirre' 
		then '0' when t0."Ejecutivo" = 'Félix Ibarra' 
		then '0' when t0."Ejecutivo" = 'Aramis Eduardo Ibarra Garcia' 
		end as "Noviembre",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		end as "Diciembre",
	 Case when t0."Ejecutivo" = '-Ningún empleado del departamento de ventas-' 
		then '0' when t0."Ejecutivo" = 'Isaura Garcia' 
		then '0' when t0."Ejecutivo" = 'Andrea Villavicencio' 
		then '0' when t0."Ejecutivo" = 'Laura Angeles' 
		then '0' when t0."Ejecutivo" = 'Rogelio Maya' 
		then '0' when t0."Ejecutivo" = 'Oscar Correa' 
		then '0' when t0."Ejecutivo" = 'Israel Garcia' 
		then '0' when t0."Ejecutivo" = 'Cynthia Araujo' 
		then '0' when t0."Ejecutivo" = 'José Luis Mandujano' 
		then '0' when t0."Ejecutivo" = 'Fernando Lopez' 
		then '0' when t0."Ejecutivo" = 'Anabel Sanchez' 
		then '0' when t0."Ejecutivo" = 'Ascencio Torres Mabel' 
		then '0' when t0."Ejecutivo" = 'Vacante' 
		then '0' when t0."Ejecutivo" = 'Ruben Recendez' 
		then '0' when t0."Ejecutivo" = 'Pasillas Evangelista Alma Marlene' 
		then '0' when t0."Ejecutivo" = 'Dalia Nayelli Hernández Yañez' 
		then '0' when t0."Ejecutivo" = 'Ricardo Villalvazo' 
		then '0' when t0."Ejecutivo" = 'Javier Vázquez' 
		then '0' when t0."Ejecutivo" = 'Andrés Elizarraras' 
		then '0' when t0."Ejecutivo" = 'Juan Carlos Dávalos' 
		then '0' when t0."Ejecutivo" = 'Ary Barrón' 
		then '0' when t0."Ejecutivo" = 'Edith Martinez' 
		then '0' when t0."Ejecutivo" = 'Emmanuel Salcedo' 
		then '0' when t0."Ejecutivo" = 'Diego Acosta' 
		then '0' when t0."Ejecutivo" = 'José González Ascencio' 
		end as "Total" 
		from "Venta_detallada" t0 
		WHERE NOT T0."Ejecutivo" IN ( 'Rojas Rodriguez María Celeste',
	 'Paola Paredes',
	 'Karen Delgadillo',
	 'Leonor Muñoz',
	 'Ana Cecilia Torres',
	 'Antonio Lezama Maria De Los Angeles',
	 'Celeste Rojas',
	 'Cristian Ortega',
	 'Esmeralda Alcántar',
	 'Gloria Robles',
	 'Isarel orozco Ibarra',
	 'Luis Cabrera',
	 'Luis Quintero',
	 'Mabel Ascencio',
	 'Marco Antonio Archundia',
	 'Ramon Sanchez',
	 'Robles Ibarra Gloria Emilia',
	 'Sergio Rodriguez',
	 'Veronica Martinez' ) 
		group by t0."Ejecutivo") 
	UNION ALL (select
	 t10."Ejecutivo" as "Agentes",
	 'Real' as "U/M",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Enero 2019' ) AS "Enero",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Febrero 2019' ) AS "Febrero",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Marzo 2019' ) AS "Marzo",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Abril 2019' ) AS "Abril",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Mayo 2019' ) AS "Mayo",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Junio 2019') AS "Junio",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Julio 2019' ) AS "Julio",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Agosto 2019' ) AS "Agosto",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Septiembre 2019' ) AS "Septiembre",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Octubre 2019' ) AS "Octubre",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Noviembre 2019' ) AS "Noviembre",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where T3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" = 'Diciembre 2019' ) AS "Diciembre",
	 (Select
	 CASE WHEN SUM(t3."USD Precio Total") > 0 
			THEN SUM(t3."USD Precio Total") 
			ELSE '0' 
			END 
			FROM "Venta_detallada" t3 
			where t3."Ejecutivo" = T10."Ejecutivo" 
			and t3."Periodo" LIKE '% 2019' ) AS "Total" 
		FROM "Venta_detallada" t10 
		WHERE NOT T10."Ejecutivo" IN ( 'Rojas Rodriguez María Celeste',
	 'Paola Paredes',
	 'Karen Delgadillo',
	 'Leonor Muñoz',
	 'Ana Cecilia Torres',
	 'Antonio Lezama Maria De Los Angeles',
	 'Celeste Rojas',
	 'Cristian Ortega',
	 'Esmeralda Alcántar',
	 'Gloria Robles',
	 'Isarel orozco Ibarra',
	 'Luis Cabrera',
	 'Luis Quintero',
	 'Mabel Ascencio',
	 'Marco Antonio Archundia',
	 'Ramon Sanchez',
	 'Robles Ibarra Gloria Emilia',
	 'Sergio Rodriguez',
	 'Veronica Martinez' ) 
		Group by t10."Ejecutivo") 
	order by "Agentes" ASC,
	 "U/M") WITH READ ONLY

QUERY PARA SACAR EL TOTAL GENERAL DE META

(
SELECT 
'Total general USD' AS "Agentes",
t11."U/M" as "U/M",
	 Sum(t11."Enero") as "Enero",	
	 Sum(t11."Febrero") as "Febrero",		
	 Sum(t11."Marzo") 	 as "Marzo",	
	 Sum(t11."Abril") 	as "Abril",		
	 Sum(t11."Mayo") 	as "Mayo",		
	 Sum(t11."Junio") 	as "Junio",		
	 Sum(t11."Julio") 	as "Julio",	
	 Sum(t11."Agosto") 	 as"Agosto",	
	 Sum(t11."Septiembre") 	as"Septiembre",		
	 Sum(t11."Octubre") 	as "Octubre",		
	 Sum(t11."Noviembre") as "Noviembre",	
	 Sum(t11."Diciembre") 	as "Diciembre",		
	 Sum(t11."Total") 	 as "Total"	
from "Ventas_agente_mensual_2019" t11
where t11."U/M" = 'Meta'
Group by 'Total general',
	 t11."U/M")

QUERY PARA SACAR TOTAL GENERAL DE REAL :slight_smile:

(
SELECT 
'Total general USD' AS "Agentes",
t11."U/M" as "U/M",
	 Sum(t11."Enero") as "Enero",	
	 Sum(t11."Febrero") as "Febrero",		
	 Sum(t11."Marzo") 	 as "Marzo",	
	 Sum(t11."Abril") 	as "Abril",		
	 Sum(t11."Mayo") 	as "Mayo",		
	 Sum(t11."Junio") 	as "Junio",		
	 Sum(t11."Julio") 	as "Julio",	
	 Sum(t11."Agosto") 	 as"Agosto",	
	 Sum(t11."Septiembre") 	as"Septiembre",		
	 Sum(t11."Octubre") 	as "Octubre",		
	 Sum(t11."Noviembre") as "Noviembre",	
	 Sum(t11."Diciembre") 	as "Diciembre",		
	 Sum(t11."Total") 	 as "Total"	
from "Ventas_agente_mensual_2019" t11
where t11."U/M" = 'Real'
Group by 'Total general',
	 t11."U/M")

A esos tres querys son a los que intente unirlos.

Gracias a todos.

Hola, @Joceline has hecho el union directo?, es decir para que una union respete el order by debes ponerlo al final.

SELECT * FROM "ASC_MEX"."Ventas_agente_mensual_2019"
UNION
SELECT ...
UNION
SELECT ...
ORDER BY "Agentes" ASC,"U/M"

Verifica y nos avisas.

3 Me gusta

Hola! Mucha gracias por responder!
Si, si hice la union directa como mencionas pero al poner el order by al final todos los union se ordenan y el total me sale antes de la ultima fila ya que como los estoy ordenando por “Agentes” y el nombre del ‘Agente’ para el union del total se llama ‘Total USD’ pues me lo ordena en donde va la ‘T’, pero yo quiero que el union del Total me salga hasta abajo pero que los registros de mi query principal sin estén ordenados alfabeticamente por ‘Agente’ y por “U/M”.

Mira asi me queda:

Pero yo quiero que el ‘Total USD’ Me quede hasta el final

Pues se me ocurre lo siguiente

SELECT * FROM "ASC_MEX"."Ventas_agente_mensual_2019"
UNION ALL
SELECT ...
UNION ALL
SELECT ...
ORDER BY "Agentes" ASC,"U/M"

Verifica tus resultados y si contiene lo que deseas.

1 me gusta

Este tema se cerró automáticamente 91 días después del último post. No se permiten nuevas respuestas.