-- Consulta alternativa para obter resultados eleitorais do ano de 2022 apenas para municípios do estado de São Paulo
-- Sem usar a tabela de municípios, filtrando pelos códigos dos municípios de São Paulo diretamente

SELECT 
    id_municipio,
    numero_candidato,
    EXTRACT(YEAR FROM data_eleicao) AS ano_eleicao,
    quantidade_votos,
    percentual_votos
FROM 
    `basedosdados.br_tse_eleicoes.resultados_candidato_municipio`
WHERE 
    EXTRACT(YEAR FROM data_eleicao) = 2022
    AND CAST(id_municipio AS INT64) IN (
        -- Lista dos códigos IBGE dos municípios do estado de São Paulo
        3500105, 3500204, 3500303, 3500402, 3500501, 3500550, 3500600, 3500709, 3500758, 3500808,
        3500907, 3501004, 3501103, 3501152, 3501202, 3501301, 3501400, 3501509, 3501608, 3501707,
        3501806, 3501905, 3502002, 3502101, 3502200, 3502309, 3502408, 3502507, 3502606, 3502705,
        3502754, 3502804, 3502903, 3503000, 3503109, 3503158, 3503208, 3503307, 3503406, 3503505,
        3503604, 3503703, 3503802, 3503901, 3503950, 3504008, 3504107, 3504206, 3504305, 3504404,
        3504503, 3504602, 3504701, 3504800, 3504909, 3505005, 3505104, 3505203, 3505302, 3505351,
        3505401, 3505500, 3505609, 3505708, 3505807, 3505906, 3506003, 3506102, 3506201, 3506300,
        3506359, 3506409, 3506508, 3506607, 3506706, 3506805, 3506904, 3507001, 3507100, 3507159,
        3507209, 3507308, 3507407, 3507456, 3507506, 3507605, 3507704, 3507753, 3507803, 3507902,
        3508009, 3508108, 3508207, 3508306, 3508405, 3508504, 3508603, 3508702, 3508801, 3508900,
        3509007, 3509106, 3509205, 3509254, 3509304, 3509403, 3509452, 3509502, 3509601, 3509700,
        3509809, 3509908, 3509957, 3510005, 3510104, 3510203, 3510302, 3510401, 3510500, 3510609,
        3510708, 3510807, 3510906, 3511003, 3511102, 3511201, 3511300, 3511409, 3511508, 3511607,
        3511706, 3511904, 3512001, 3512100, 3512209, 3512308, 3512407, 3512506, 3512605, 3512704,
        3512803, 3512902, 3513009, 3513108, 3513207, 3513306, 3513405, 3513504, 3513603, 3513702,
        3513801, 3513850, 3513900, 3514007, 3514106, 3514205, 3514304, 3514403, 3514502, 3514601,
        3514700, 3514809, 3514908, 3515004, 3515103, 3515202, 3515301, 3515350, 3515400, 3515509,
        3515608, 3515657, 3515707, 3515806, 3515905, 3516002, 3516101, 3516200, 3516309, 3516408,
        3516507, 3516606, 3516705, 3516804, 3516853, 3516903, 3517000, 3517109, 3517208, 3517307,
        3517406, 3517505, 3517604, 3517703, 3517802, 3517901, 3518008, 3518107, 3518206, 3518305,
        3518404, 3518503, 3518602, 3518701, 3518800, 3518859, 3518909, 3519006, 3519055, 3519071,
        3519105, 3519204, 3519253, 3519303, 3519402, 3519501, 3519600, 3519709, 3519808, 3519907,
        3520004, 3520103, 3520202, 3520301, 3520400, 3520509, 3520608, 3520707, 3520806, 3520905,
        3521002, 3521101, 3521150, 3521200, 3521309, 3521408, 3521507, 3521606, 3521705, 3521804,
        3521903, 3522000, 3522109, 3522158, 3522208, 3522307, 3522406, 3522505, 3522604, 3522653,
        3522703, 3522802, 3522901, 3523008, 3523107, 3523206, 3523305, 3523404, 3523503, 3523602,
        3523701, 3523800, 3523909, 3524006, 3524105, 3524204, 3524303, 3524402, 3524501, 3524600,
        3524709, 3524808, 3524907, 3525003, 3525102, 3525201, 3525300, 3525409, 3525508, 3525607,
        3525706, 3525805, 3525904, 3526001, 3526100, 3526209, 3526308, 3526407, 3526506, 3526605,
        3526704, 3526803, 3526902, 3527009, 3527108, 3527207, 3527306, 3527405, 3527504, 3527603,
        3527702, 3527801, 3527900, 3528007, 3528106, 3528205, 3528304, 3528403, 3528502, 3528601,
        3528700, 3528809, 3528858, 3528908, 3529005, 3529104, 3529203, 3529302, 3529401, 3529500,
        3529609, 3529708, 3529807, 3529906, 3530003, 3530102, 3530201, 3530300, 3530409, 3530508,
        3530607, 3530706, 3530805, 3530904, 3531001, 3531100, 3531209, 3531308, 3531407, 3531506,
        3531605, 3531704, 3531803, 3531902, 3532009, 3532108, 3532207, 3532306, 3532405, 3532504,
        3532603, 3532702, 3532801, 3532900, 3533007, 3533106, 3533205, 3533304, 3533403, 3533502,
        3533601, 3533700, 3533809, 3533908, 3534005, 3534104, 3534203, 3534302, 3534401, 3534500,
        3534609, 3534708, 3534807, 3534906, 3535002, 3535101, 3535200, 3535309, 3535408, 3535507,
        3535606, 3535705, 3535804, 3535903, 3536000, 3536109, 3536208, 3536307, 3536406, 3536505,
        3536604, 3536703, 3536802, 3536901, 3537008, 3537107, 3537206, 3537305, 3537404, 3537503,
        3537602, 3537701, 3537800, 3537909, 3538006, 3538105, 3538204, 3538303, 3538402, 3538501,
        3538600, 3538709, 3538808, 3538907, 3539004, 3539103, 3539202, 3539301, 3539400, 3539509,
        3539608, 3539707, 3539806, 3539905, 3540002, 3540101, 3540200, 3540309, 3540408, 3540507,
        3540606, 3540705, 3540804, 3540903, 3541000, 3541059, 3541109, 3541208, 3541307, 3541406,
        3541505, 3541604, 3541653, 3541703, 3541802, 3541901, 3542008, 3542107, 3542206, 3542305,
        3542404, 3542503, 3542602, 3542701, 3542800, 3542909, 3543006, 3543105, 3543204, 3543303,
        3543402, 3543501, 3543600, 3543709, 3543808, 3543907, 3544004, 3544103, 3544202, 3544301,
        3544400, 3544509, 3544608, 3544707, 3544806, 3544905, 3545001, 3545100, 3545209, 3545308,
        3545407, 3545506, 3545605, 3545704, 3545803, 3545902, 3546009, 3546108, 3546207, 3546306,
        3546405, 3546504, 3546603, 3546702, 3546801, 3546900, 3547007, 3547106, 3547155, 3547205,
        3547304, 3547403, 3547502, 3547601, 3547700, 3547809, 3547908, 3548005, 3548104, 3548203,
        3548302, 3548401, 3548500, 3548609, 3548708, 3548807, 3548906, 3549003, 3549102, 3549201,
        3549300, 3549409, 3549508, 3549607, 3549706, 3549805, 3549904, 3550001, 3550100, 3550209,
        3550308, 3550407, 3550506, 3550605, 3550704, 3550803, 3550902, 3551009, 3551108, 3551207,
        3551306, 3551405, 3551504, 3551603, 3551900, 3552007, 3552106, 3552205, 3552304, 3552403,
        3552502, 3552601, 3552700, 3552809, 3552908, 3553005, 3553104, 3553203, 3553302, 3553401,
        3553500, 3553609, 3553708, 3553807, 3553906, 3554003, 3554102, 3554201, 3554300, 3554409,
        3554508, 3554607, 3554706, 3554805, 3554904, 3555000, 3555109, 3555208, 3555307, 3555406,
        3555505, 3555604, 3555703, 3555802, 3555901, 3556008, 3556107, 3556206, 3556305, 3556404,
        3556503, 3556602, 3556701, 3556800, 3556909, 3557006, 3557105, 3557204, 3557303, 3557402,
        3557501, 3557600, 3557709, 3557808, 3557907, 3558004, 3558103, 3558202, 3558301, 3558400,
        3558509, 3558608, 3558707, 3558806, 3558905, 3559002, 3559101, 3559200, 3559309, 3559408,
        3559507, 3559606, 3559705, 3559804, 3559903, 3560000, 3560109, 3560208, 3560307, 3560406,
        3560505, 3560604, 3560703, 3560802, 3560901, 3561008, 3561107, 3561206, 3561305, 3561404,
        3561503, 3561602, 3561701, 3561800, 3561909, 3562006, 3562105, 3562204, 3562303, 3562402,
        3562501, 3562600, 3562709, 3562808, 3562907, 3563004, 3563103, 3563202, 3563301, 3563400,
        3563509, 3563608, 3563707, 3563806, 3563905, 3564002, 3564101, 3564200, 3564309, 3564408,
        3564507, 3564606, 3564705, 3564804, 3564903, 3565002, 3565101, 3565200, 3565309, 3565408,
        3565507, 3565606, 3565705, 3565804, 3565903, 3566000, 3566109, 3566208, 3566307, 3566406,
        3566505, 3566604, 3566703, 3566802, 3566901, 3567008, 3567107, 3567206, 3567305, 3567404,
        3567503, 3567602, 3567701, 3567800, 3567909, 3568006, 3568105, 3568204, 3568303, 3568402,
        3568501, 3568600, 3568709, 3568808, 3568907, 3569004, 3569103, 3569202, 3569301, 3569400,
        3569509, 3569608, 3569707, 3569806, 3569905, 3570002, 3570101, 3570200, 3570309, 3570408,
        3570507, 3570606, 3570705, 3570804, 3570903, 3571000, 3571109, 3571208, 3571307, 3571406,
        3571505, 3571604, 3571703, 3571802, 3571901, 3572008, 3572107, 3572206, 3572305, 3572404,
        3572503, 3572602, 3572701, 3572800, 3572909, 3573006, 3573105, 3573204, 3573303, 3573402,
        3573501, 3573600, 3573709, 3573808, 3573907, 3574004, 3574103, 3574202, 3574301, 3574400,
        3574509, 3574608, 3574707, 3574806, 3574905, 3575001, 3575100, 3575209, 3575308, 3575407,
        3575506, 3575605, 3575704, 3575803, 3575902, 3576009, 3576108, 3576207, 3576306, 3576405,
        3576504, 3576603, 3576702, 3576801, 3576900, 3577007, 3577106, 3577205, 3577304, 3577403,
        3577502, 3577601, 3577700, 3577809, 3577908, 3578005, 3578104, 3578203, 3578302, 3578401,
        3578500, 3578609, 3578708, 3578807, 3578906, 3579003, 3579102, 3579201, 3579300, 3579409,
        3579508, 3579607, 3579706, 3579805, 3579904, 3580001, 3580100, 3580209, 3580308, 3580407,
        3580506, 3580605, 3580704, 3580803, 3580902, 3581009, 3581108, 3581207, 3581306, 3581405,
        3581504, 3581603, 3581702, 3581801, 3581900, 3582007, 3582106, 3582205, 3582304, 3582403,
        3582502, 3582601, 3582700, 3582809, 3582908, 3583005, 3583104, 3583203, 3583302, 3583401,
        3583500, 3583609, 3583708, 3583807, 3583906, 3584003, 3584102, 3584201, 3584300, 3584409,
        3584508, 3584607, 3584706, 3584805, 3584904, 3585000, 3585109, 3585208, 3585307, 3585406,
        3585505, 3585604, 3585703, 3585802, 3585901, 3586008, 3586107, 3586206, 3586305, 3586404,
        3586503, 3586602, 3586701, 3586800, 3586909, 3587006, 3587105, 3587204, 3587303, 3587402,
        3587501, 3587600, 3587709, 3587808, 3587907, 3588004, 3588103, 3588202, 3588301, 3588400,
        3588509, 3588608, 3588707, 3588806, 3588905, 3589002, 3589101, 3589200, 3589309, 3589408,
        3589507, 3589606, 3589705, 3589804, 3589903, 3590000, 3590109, 3590208, 3590307, 3590406,
        3590505, 3590604, 3590703, 3590802, 3590901, 3591008, 3591107, 3591206, 3591305, 3591404,
        3591503, 3591602, 3591701, 3591800, 3591909, 3592006, 3592105, 3592204, 3592303, 3592402,
        3592501, 3592600, 3592709, 3592808, 3592907, 3593004, 3593103, 3593202, 3593301, 3593400,
        3593509, 3593608, 3593707, 3593806, 3593905, 3594002, 3594101, 3594200, 3594309, 3594408,
        3594507, 3594606, 3594705, 3594804, 3594903, 3595009, 3595108, 3595207, 3595306, 3595405,
        3595504, 3595603, 3595702, 3595801, 3595900, 3596007, 3596106, 3596205, 3596304, 3596403,
        3596502, 3596601, 3596700, 3596809, 3596908, 3597005, 3597104, 3597203, 3597302, 3597401,
        3597500, 3597609, 3597708, 3597807, 3597906, 3598003, 3598102, 3598201, 3598300, 3598409,
        3598508, 3598607, 3598706, 3598805, 3598904, 3599001, 3599100, 3599209, 3599308, 3599407,
        3599506, 3599605, 3599704, 3599803, 3599902, 3500105
    )
