Hi Everyone!
I have a priority column which can give only 3 different results (High or Normal or Low).
I have another column named Hour Diff which gives me hours difference between date time difference from two other columns.
Basically I would like to do the following:
Based on Priority:
High 6hrs = 06:00:00
Normal 36hrs = 36:00:00
Low 220hrs = 220:00:00
i.e. If Priority field = high then if Hour Diff is > 06:00:00 then SLA Met column = No otherwise Yes
i.e. If Priority field = Normal then if Hour Diff is > 36:00:00 then SLA Met column = No otherwise Yes
i.e. If Priority field = low then if Hour Diff is > 220:00:00 then SLA Met column = No otherwise Yes
Below my current mysql code:
select HD_TICKET.ID,
HD_TICKET.TITLE ,
HD_TICKET.DUE_DATE ,
DATE_FORMAT(HD_TICKET.TIME_CLOSED, '%m/%d/%Y %H:%i') as TIME_CLOSED,
TIME_FORMAT(TIMEDIFF(HD_TICKET.DUE_DATE, HD_TICKET.TIME_CLOSED),'%H') AS HOUR_DIFF,
HD_PRIORITY.NAME as PRIORITY,
HD_CATEGORY.NAME as CATEGORY,
HD_STATUS.NAME as STATUS,
HD_IMPACT.NAME as IMPACT,
MACHINE.NAME as MACHINE_NAME,
ifnull((select FULL_NAME from USER where HD_TICKET.OWNER_ID = USER.ID),' Unassigned') as OWNER_NAME,
(select FULL_NAME from USER where HD_TICKET.SUBMITTER_ID = USER.ID) as SUBMITTER_NAME
from HD_TICKET
left join HD_CATEGORY on HD_CATEGORY_ID = HD_CATEGORY.ID
left join HD_STATUS on HD_STATUS_ID = HD_STATUS.ID
left join HD_PRIORITY on HD_PRIORITY_ID = HD_PRIORITY.ID
left join HD_IMPACT on HD_IMPACT_ID = HD_IMPACT.ID
left join MACHINE on HD_TICKET.MACHINE_ID = MACHINE.ID
where HD_STATUS.STATE = 'closed' and HD_TICKET.TIME_CLOSED > DATE_SUB(NOW(), INTERVAL 31 DAY)
order by OWNER_NAME, HD_PRIORITY.ORDINAL, HD_CATEGORY.ORDINAL, HD_STATUS.ORDINAL, HD_IMPACT.ORDINAL
Thank you for you support!
I have a priority column which can give only 3 different results (High or Normal or Low).
I have another column named Hour Diff which gives me hours difference between date time difference from two other columns.
Basically I would like to do the following:
Based on Priority:
High 6hrs = 06:00:00
Normal 36hrs = 36:00:00
Low 220hrs = 220:00:00
i.e. If Priority field = high then if Hour Diff is > 06:00:00 then SLA Met column = No otherwise Yes
i.e. If Priority field = Normal then if Hour Diff is > 36:00:00 then SLA Met column = No otherwise Yes
i.e. If Priority field = low then if Hour Diff is > 220:00:00 then SLA Met column = No otherwise Yes
Below my current mysql code:
select HD_TICKET.ID,
HD_TICKET.TITLE ,
HD_TICKET.DUE_DATE ,
DATE_FORMAT(HD_TICKET.TIME_CLOSED, '%m/%d/%Y %H:%i') as TIME_CLOSED,
TIME_FORMAT(TIMEDIFF(HD_TICKET.DUE_DATE, HD_TICKET.TIME_CLOSED),'%H') AS HOUR_DIFF,
HD_PRIORITY.NAME as PRIORITY,
HD_CATEGORY.NAME as CATEGORY,
HD_STATUS.NAME as STATUS,
HD_IMPACT.NAME as IMPACT,
MACHINE.NAME as MACHINE_NAME,
ifnull((select FULL_NAME from USER where HD_TICKET.OWNER_ID = USER.ID),' Unassigned') as OWNER_NAME,
(select FULL_NAME from USER where HD_TICKET.SUBMITTER_ID = USER.ID) as SUBMITTER_NAME
from HD_TICKET
left join HD_CATEGORY on HD_CATEGORY_ID = HD_CATEGORY.ID
left join HD_STATUS on HD_STATUS_ID = HD_STATUS.ID
left join HD_PRIORITY on HD_PRIORITY_ID = HD_PRIORITY.ID
left join HD_IMPACT on HD_IMPACT_ID = HD_IMPACT.ID
left join MACHINE on HD_TICKET.MACHINE_ID = MACHINE.ID
where HD_STATUS.STATE = 'closed' and HD_TICKET.TIME_CLOSED > DATE_SUB(NOW(), INTERVAL 31 DAY)
order by OWNER_NAME, HD_PRIORITY.ORDINAL, HD_CATEGORY.ORDINAL, HD_STATUS.ORDINAL, HD_IMPACT.ORDINAL
Thank you for you support!