Query Mysql Base para extração de Chamados do GLPI e uso em uma ferramenta de BI.

Apresento uma Query Base, criada com o objetivo de extrair dados de chamados da Plataforma GLPI aplicando estes dados as mais diversas ferramentas de BI Existententes.

SELECT DISTINCT
        `glpi_prd`.`glpi_tickets`.`id` AS `id`,
        `glpi_prd`.`glpi_tickets`.`name` AS `narrativa`,
        `glpi_prd`.`glpi_plugin_status_ticket`.`descricao` AS `descricao`,
        `glpi_prd`.`glpi_entities`.`completename` AS `empresa`,
        `glpi_prd`.`glpi_tickets`.`date_mod` AS `modificacao`,
        `glpi_prd`.`glpi_tickets`.`date` AS `abertura`,
        `glpi_prd`.`glpi_tickets`.`priority` AS `prioridade`,
        `glpi_prd`.`glpi_itilcategories`.`completename` AS `Categoria`,
        `glpi_prd`.`glpi_tickets`.`solvedate` AS `solucao`,
        (SELECT 
                `glpi_prd`.`glpi_users`.`name` AS `requerente`
            FROM
                (`glpi_prd`.`glpi_users`
                JOIN `glpi_prd`.`glpi_tickets_users` ON (`glpi_prd`.`glpi_users`.`id` = `glpi_prd`.`glpi_tickets_users`.`users_id`))
            WHERE
                `glpi_prd`.`glpi_tickets_users`.`type` = 1
                    AND `glpi_prd`.`glpi_tickets_users`.`tickets_id` = `glpi_prd`.`glpi_tickets`.`id`) AS `requerente`,
        (SELECT DISTINCT
                `glpi_prd`.`glpi_users`.`name` AS `tecnico`
            FROM
                (`glpi_prd`.`glpi_users`
                JOIN `glpi_prd`.`glpi_tickets_users` ON (`glpi_prd`.`glpi_users`.`id` = `glpi_prd`.`glpi_tickets_users`.`users_id`))
            WHERE
                `glpi_prd`.`glpi_tickets_users`.`type` = 2
                    AND `glpi_prd`.`glpi_tickets_users`.`tickets_id` = `glpi_prd`.`glpi_tickets`.`id`
            LIMIT 1) AS `tecnico`
    FROM
        (((((((`glpi_prd`.`glpi_tickets`
        LEFT JOIN `glpi_prd`.`glpi_entities` ON (`glpi_prd`.`glpi_tickets`.`entities_id` = `glpi_prd`.`glpi_entities`.`id`))
        LEFT JOIN `glpi_prd`.`glpi_tickets_users` `glpi_tickets_users_019878060c6d5f06cbe3c4d7c31dec24` ON (`glpi_prd`.`glpi_tickets`.`id` = `glpi_tickets_users_019878060c6d5f06cbe3c4d7c31dec24`.`tickets_id`
            AND `glpi_tickets_users_019878060c6d5f06cbe3c4d7c31dec24`.`type` = '1'))
        LEFT JOIN `glpi_prd`.`glpi_users` `glpi_users_af1042e23ce6565cfe58c6db91f84692` ON (`glpi_tickets_users_019878060c6d5f06cbe3c4d7c31dec24`.`users_id` = `glpi_users_af1042e23ce6565cfe58c6db91f84692`.`id`))
        LEFT JOIN `glpi_prd`.`glpi_tickets_users` `glpi_tickets_users_c6f7f58b9365babf7388e555e526efd5` ON (`glpi_prd`.`glpi_tickets`.`id` = `glpi_tickets_users_c6f7f58b9365babf7388e555e526efd5`.`tickets_id`
            AND `glpi_tickets_users_c6f7f58b9365babf7388e555e526efd5`.`type` = '2'))
        LEFT JOIN `glpi_prd`.`glpi_users` `glpi_users_b1b92f6be5e70531688d870931e94a65` ON (`glpi_tickets_users_c6f7f58b9365babf7388e555e526efd5`.`users_id` = `glpi_users_b1b92f6be5e70531688d870931e94a65`.`id`))
        LEFT JOIN `glpi_prd`.`glpi_itilcategories` ON (`glpi_prd`.`glpi_tickets`.`itilcategories_id` = `glpi_prd`.`glpi_itilcategories`.`id`))
        LEFT JOIN `glpi_prd`.`glpi_plugin_status_ticket` ON (`glpi_prd`.`glpi_tickets`.`status` = `glpi_prd`.`glpi_plugin_status_ticket`.`id`))
    WHERE
        `glpi_prd`.`glpi_tickets`.`is_deleted` = 0
            AND `glpi_prd`.`glpi_tickets`.`status` IN ('1' , '2', '3', '4', '5', '6')
    GROUP BY `glpi_prd`.`glpi_tickets`.`id`
    ORDER BY `glpi_prd`.`glpi_tickets`.`id`

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *