MaximoAccess

Caro Usuário, antes de postar pela primeira vez, leia as regras do fórum.

https://www.maximoaccess.com/t48-regras-do-forum

Obrigado

Administração


Participe do fórum, é rápido e fácil

MaximoAccess

Caro Usuário, antes de postar pela primeira vez, leia as regras do fórum.

https://www.maximoaccess.com/t48-regras-do-forum

Obrigado

Administração

MaximoAccess

Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Dicas Ms Access, Exemplos Ms Access, Codigos VBA Ms Access, SQL Ms Access

3 participantes

    [Resolvido]Union com mais de 50 campos

    avatar
    icruznina
    Intermediário
    Intermediário

    Respeito às regras : Respeito às Regras 100%

    Sexo : Feminino
    Localização : Brasil
    Mensagens : 58
    Registrado : 03/08/2015

    [Resolvido]Union com mais de 50 campos Empty [Resolvido]Union com mais de 50 campos

    Mensagem  icruznina 10/2/2020, 10:38

    Bom dia. Estou tendo dificuldades de criar Union com mais de 50 campos, ao rodar diz que a consulta é muito complexa. Tem como solucionar isso nas configurações do Access? Obrigada.
    Alexandre Fim
    Alexandre Fim
    Developer
    Developer

    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 1771
    Registrado : 13/12/2016

    [Resolvido]Union com mais de 50 campos Empty Re: [Resolvido]Union com mais de 50 campos

    Mensagem  Alexandre Fim 10/2/2020, 12:32

    Ivone bom dia,

    As tabelas que fazem parte da UNION deve ter os mesmos campos.

    Se possível, poste aqui seu banco de dados(somente partes envolvidas) para analise.

    Grato.
    avatar
    icruznina
    Intermediário
    Intermediário

    Respeito às regras : Respeito às Regras 100%

    Sexo : Feminino
    Localização : Brasil
    Mensagens : 58
    Registrado : 03/08/2015

    [Resolvido]Union com mais de 50 campos Empty respondendo

    Mensagem  icruznina 10/2/2020, 12:50

    eu sempre faço as unions retirando diretamente das tabelas, porém, de um tempo pra cá, faço algumas consultas e junto esses resultados na union, parece que o resultado sai mais rapido, so que não aceita mais de 50 campos, mesmo retirando diretamente das tabelas. Resultado: tive que dividir um relatorio consolidade de janeiro a dezembro em 2, de janeiro a junho e julho a dezembro, porque não roda. Daí, pensei ser uma limitação do Access, e de repente alguém aí já passou por isso. Ou será uma limitação do SQL?
    Alexandre Fim
    Alexandre Fim
    Developer
    Developer

    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 1771
    Registrado : 13/12/2016

    [Resolvido]Union com mais de 50 campos Empty Re: [Resolvido]Union com mais de 50 campos

    Mensagem  Alexandre Fim 10/2/2020, 13:05

    O número máximo de colunas que o Access suporta é 255.
    Talvez vc esteja utilizando UNION ALL para todas as tabelas, e desta forma, o Access conta o nro de colunas de todas as tabelas.
    Se vc tiver utilizando 6 tabelas com 50 campos cada 6x50 = 300), o Access vai gerar erro por número de colunas.
    Verifique também se existem campos calculados e também Texto Longo (Memorando). Estes costumam dar erros também.

    boa sorte.

    avatar
    icruznina
    Intermediário
    Intermediário

    Respeito às regras : Respeito às Regras 100%

    Sexo : Feminino
    Localização : Brasil
    Mensagens : 58
    Registrado : 03/08/2015

    [Resolvido]Union com mais de 50 campos Empty Imagem do problema

    Mensagem  icruznina 10/2/2020, 13:06

    segue uma imagem da situação


    Última edição por icruznina em 10/2/2020, 13:11, editado 1 vez(es)
    Alexandre Fim
    Alexandre Fim
    Developer
    Developer

    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 1771
    Registrado : 13/12/2016

    [Resolvido]Union com mais de 50 campos Empty Re: [Resolvido]Union com mais de 50 campos

    Mensagem  Alexandre Fim 10/2/2020, 13:08

    Ops...não veio a imagem.
    Se possivel, poste aqui seu banco de dados (omente partes envolvidas) para analise.
    avatar
    icruznina
    Intermediário
    Intermediário

    Respeito às regras : Respeito às Regras 100%

    Sexo : Feminino
    Localização : Brasil
    Mensagens : 58
    Registrado : 03/08/2015

    [Resolvido]Union com mais de 50 campos Empty copia do texto da union

    Mensagem  icruznina 10/2/2020, 13:19

    SELECT COUNT(*) AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE (TOTALSCFV.IDADEC<=5) UNION ALL
    SELECT 0 AS TOT0A5, COUNT(*) AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE (TOTALSCFV.IDADEC BETWEEN 6 AND 11) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, COUNT(*) AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE (TOTALSCFV.IDADEC BETWEEN 12 AND 14) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, COUNT(*) AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE (TOTALSCFV.IDADEC BETWEEN 15 AND 17) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, COUNT(*) AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE (TOTALSCFV.IDADEC BETWEEN 18 AND 29) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, COUNT(*) AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE ((TOTALSCFV.IDADET BETWEEN 18 AND 29) AND (TOTALSCFV.COMPOS is null)) union all
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, COUNT(*) AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE (TOTALSCFV.IDADEC BETWEEN 30 AND 59) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, COUNT(*) AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE ((TOTALSCFV.IDADET BETWEEN 30 AND 59) AND (TOTALSCFV.COMPOS is null)) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, COUNT(*) AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE (TOTALSCFV.IDADEC >=60) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, COUNT(*) AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA TOTAL INSC] AS TOTALSCFV
    WHERE ((TOTALSCFV.IDADET >=60) AND (TOTALSCFV.COMPOS is null)) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, COUNT(*) AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND ([INCLUSCFV].[IdadeC] <=5) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) union all
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, COUNT(*) AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND ([INCLUSCFV].IDADEC BETWEEN 6 AND 11) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, COUNT(*) AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND ([INCLUSCFV].IDADEC BETWEEN 12 AND 14) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, COUNT(*) AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND ([INCLUSCFV].IDADEC BETWEEN 15 AND 17) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, COUNT(*) AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND ([INCLUSCFV].IDADEC BETWEEN 18 AND 29) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, COUNT(*) AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND (INCLUSCFV.IDADET BETWEEN 18 AND 29) AND ([INCLUSCFV].[COMPOS] is null) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, COUNT(*) AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND (INCLUSCFV.IDADEC BETWEEN 30 AND 59) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, COUNT(*) AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND (INCLUSCFV.IDADET BETWEEN 30 AND 59) AND ([INCLUSCFV].[COMPOS] is null) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, COUNT(*) AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND (INCLUSCFV.IDADEC >=60) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, COUNT(*) AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA INCLU] AS INCLUSCFV
    WHERE (([INCLUSCFV].[DATA INSCRIÇÃO]) Between [DATA INICIAL]  And [DATA FINAL]) AND (INCLUSCFV.IDADET >=60) AND ([INCLUSCFV].[COMPOS] is null) AND (([INCLUSCFV].[DATA SAÍDA]) Is Null) UNION ALL

    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, COUNT(*) AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA EXCLU] AS EXCLUSCFV
    WHERE (([EXCLUSCFV].[DATA SAÍDA]) Between [DATA INICIAL]  And [DATA FINAL]) AND (EXCLUSCFV.IDADEC <=5) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, COUNT(*) AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA EXCLU] AS EXCLUSCFV
    WHERE (([EXCLUSCFV].[DATA SAÍDA]) Between [DATA INICIAL]  And [DATA FINAL]) AND (EXCLUSCFV.IDADEC BETWEEN 6 AND 11) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, COUNT(*) AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA EXCLU] AS EXCLUSCFV
    WHERE (([EXCLUSCFV].[DATA SAÍDA]) Between [DATA INICIAL]  And [DATA FINAL]) AND (EXCLUSCFV.IDADEC BETWEEN 12 AND 14) UNION ALL
    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, COUNT(*) AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX ETARIA EXCLU] AS EXCLUSCFV
    WHERE (([EXCLUSCFV].[DATA SAÍDA]) Between [DATA INICIAL]  And [DATA FINAL]) AND (EXCLUSCFV.IDADEC BETWEEN 15 AND 17) UNION ALL


    .........(recortei porque não enviou)
    ..............
    ...........



    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, COUNT(*) AS SIT60MC, 0 AS SIT60MT
    FROM [PERFIL SCFV FX 60MAIS SIT PRIORI COMPO] UNION ALL




    SELECT 0 AS TOT0A5, 0 AS TOT6A11, 0 AS TOT12A14, 0 AS TOT15A17, 0 AS TOT18A29C, 0 AS TOT18A29T, 0 AS TOT30A59C, 0 AS TOT30A59T, 0 AS TOT60MC, 0 AS TOT60MT, 0 AS INCLU0A5, 0 AS INCLU6A11, 0 AS INCLU12A14, 0 AS INCLU15A17, 0 AS INCLU18A29C, 0 AS INCLU18A29T, 0 AS INCLU30A59C, 0 AS INCLU30A59T, 0 AS INCLU60MC, 0 AS INCLU60MT, 0 AS EXCLU0A5, 0 AS EXCLU6A11, 0 AS EXCLU12A14, 0 AS EXCLU15A17, 0 AS EXCLU18A29C, 0 AS EXCLU18A29T, 0 AS EXCLU30A59C, 0 AS EXCLU30A59T, 0 AS EXCLU60MC, 0 AS EXCLU60MT, 0 AS PRE0A5, 0 AS PRE6A11, 0 AS PRE12A14, 0 AS PRE15A17, 0 AS PRE18A29C, 0 AS PRE18A29T, 0 AS PRE30A59C, 0 AS PRE30A59T, 0 AS PRE60C, 0 AS PRE60T, 0 AS SIT0A5, 0 AS SIT6A11, 0 AS SIT12A14, 0 AS SIT15A17, 0 AS SIT18A29C, 0 AS SIT18A29T, 0 AS SIT30A59C, 0 AS SIT30A59T, 0 AS SIT60MC, COUNT(*) AS SIT60MT
    FROM [PERFIL SCFV FX 60MAIS SIT PRIORI TITULAR];



    como vc pode perceber, são 50 campos. quando eu divido, roda a consulta

    quando eu elimino esse ultimo select a consulta roda
    Alexandre Neves
    Alexandre Neves
    Moderador Global
    Moderador Global

    Respeito às regras : Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 8019
    Registrado : 05/11/2009

    [Resolvido]Union com mais de 50 campos Empty Re: [Resolvido]Union com mais de 50 campos

    Mensagem  Alexandre Neves 10/2/2020, 17:37

    Boa tarde,
    Pelo que percebi da consulta, trata-se de consulta UNION atípica, podendo ser muito melhorada
    1- Nomeie de forma normalizada (nomes sem espaços-em vez de DATA FINAL utilize DataFinal)
    2- Não utilize Campo is Null mas IsNull(Campo)
    3- coloque a expressão da consulta que pretende utilizar para poder ajudar a simplificar


    .................................................................................
    Access 2010. Mande bd que dê para testar (indique a versão). Não peça para fazer o que já tem feito. Dê todos os detalhes.
    Não coloquem entraves como senhas, esconder controlos, etc. Disponibilizem o mais limpo possível
    Só respondo a mensagens privadas, se forem de assunto privado; às outras não respondo.
    Quem trabalha e mata a fome não come o pão de ninguém; mas quem não trabalha e come, come sempre o pão de alguém. António Aleixo
    avatar
    icruznina
    Intermediário
    Intermediário

    Respeito às regras : Respeito às Regras 100%

    Sexo : Feminino
    Localização : Brasil
    Mensagens : 58
    Registrado : 03/08/2015

    [Resolvido]Union com mais de 50 campos Empty consegui

    Mensagem  icruznina 11/2/2020, 12:13

    Bom dia! Dividi a consulta e 2, criei a sum dessas 2 unions, juntei as 2 sums e uma nova consulta, deu certo. Obrigada a todos.

      Data/hora atual: 17/9/2021, 05:47