Bom dia Pessoal,
Estou precisando muito da ajuda de voces para transformas está consulta que está me dando o resultado em linha em colunas, se alguem puder me ajudar fico muito grato.
Query
( SELECT 'F16'AS FILFOR, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_16 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('116','1013') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F30'AS NOME_IMPOSTO, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_30 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('130','1030') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F40'AS NOME_IMPOSTO, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_40 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('104','1018') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F46'AS NOME_IMPOSTO, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_46 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('1014','1016') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F51'AS NOME_IMPOSTO, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_51 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('110','1019') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F52'AS NOME_IMPOSTO, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_52 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('111','1020') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F60'AS NOME_IMPOSTO, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_60 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('106') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F70'AS NOME_IMPOSTO , SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_70 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('107','1012') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F72'AS NOME_IMPOSTO, SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_72 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('117','1021') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123'
UNION ALL SELECT 'F73'AS NOME_IMPOSTO , SUM(SE2.E2_VALOR - SE2.E2_SDDECRE + SE2.E2_ACRESC - SE2.E2_DESCONT) AS F_73 FROM SE2010 SE2 WHERE SE2.D_E_L_E_T_ = ' ' AND SE2.E2_FILIAL IN ('01','16','30','40','46','51','52','60','70','72','73','80') AND SE2.E2_NATUREZ IN ('118') AND SE2.E2_BAIXA BETWEEN '20211101' AND '20211123')