Paste


Paste whatever you want here.



SELECT DISTINCT
        s.state_id,
        z2d.zip5,
        z2d.zip4end,
        z2d.zip4start,
        candidate_id
    FROM zip2district z2d
    JOIN state s USING (statecode)
    JOIN district d
        ON d.state_id = s.state_id
    JOIN office_candidate oc ON oc.office_id = d.office_id AND d.districtname_id = oc.districtname_id
    JOIN django.misc_userprofile mu
        ON mu.track_officials_email IS TRUE
        AND (mu.zip5 IS NOT NULL AND mu.zip5 != '')
        AND mu.zip5::int = z2d.zip5
        AND (
            mu.zip4 IS NOT NULL
            AND mu.zip4 != ''
            AND mu.zip4::int > z2d.zip4start
            AND mu.zip4::int < z2d.zip4end
        )
    WHERE oc.officecandidatestatus_id = 1
    AND (
        (d.zip2districtcode = z2d.ushouse AND oc.office_id = 5)
        OR (d.zip2districtcode = z2d.stateupper AND oc.office_id = 9)
        OR (d.zip2districtcode = z2d.statelower AND oc.office_id IN (7,8))
        OR oc.office_id NOT IN (5,7,8,9)
    )
    ORDER BY s.state_id, z2d.zip5, z2d.zip4start, z2d.zip4end;
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki