MySQL Forums
Forum List  »  Spanish

Consulta retorna tabla en blanco
Posted by: Eduardo Estay
Date: January 31, 2023 11:31AM

Estoy tratando de ejecutar una consulta para calcular el tiempo para resolver algunos tickets en la base de datos otrs. Mi empresa me dio la consulta hecha (funciona correctamente), sin embargo, me trae solo columnas en blanco. He estado revisando la consulta y todas las tablas a las que hace referencia tienen datos y no entiendo porque no trae datos. Esta consulta lo que hace es calcular el tiempo desde que se crea un ticket hasta que se resuelve, sin embargo el usuario puede pausar el tiempo de respuesta y volver a iniciarlo espero me puedan ayudar.

Espero recibir datos en las columnas. Tengo una tabla llamada "Data" en la que se ha llenado de fechas genéricas cada 1 minuto que me ayuda a calcular la función Total_hh_nueva, sin embargo, no entiendo cómo se relaciona con la consulta para calcular el tiempo.


select
t.tn as ticket,
t.sla_id as id_tipo_sla,
s.name as nombre_sla,
1 as contador,
t.create_time,
t.change_time,
(select min(tt.create_time) from ticket_history tt,
ticket_state e
where tt.ticket_id=t.id
and tt.article_id is not null
and tt.state_id=e.id
and tt.state_id<>1
) fecha_primer_cambio,
case
when
30>total_hh_nueva(DATE_FORMAT(t.create_time, "%Y,%m,%d %H,%i"), DATE_FORMAT((select min(tt.create_time) from ticket_history tt
,ticket_state e
where tt.ticket_id=t.id
and tt.article_id is not null
and tt.state_id=e.id
and tt.state_id<>1), "%Y,%m,%d %H,%i")) then 1
else 0 end as Cumple,
30 as sla,
total_hh_nueva(DATE_FORMAT(t.create_time, "%Y,%m,%d %H,%i"), DATE_FORMAT((select min(tt.create_time) from ticket_history tt,
ticket_state e
where tt.ticket_id=t.id
and tt.article_id is not null
and tt.state_id=e.id
and tt.state_id<>1), "%Y,%m,%d %H,%i")) tiemporeal,
u.login usuario
from ticket t,
sla s,
users u
where
t.create_time BETWEEN "2022/01/01"
AND "2022/12/31" + interval 1439 minute
and t.type_id in (1,8) /*8: Requerimiento 1:Indicente*/
and t.sla_id=s.id
and t.user_id=u.id
and t.queue_id in (8) /*Solo mesa de ayuda*/
/*and t.ticket_state_id in (2,3,10,13,14) /*Estado Cerrados Solamente*/

Options: ReplyQuote


Subject
Views
Written By
Posted
Consulta retorna tabla en blanco
512
January 31, 2023 11:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.