Find when a program is down by selected date or dates.
Hello all, I have a report that I can run and find out when a single select is selected and find when a program is down. Now this sql code only runs for that given day. How would I add to this sql code to be able to make changes and select a date or dates I would like this to run. Below is the code I have so far for my report. Thank you.
SELECT HD_TICKET.CREATED AS CREATED, HD_TICKET.TIME_OPENED AS OPENED, HD_TICKET.TIME_CLOSED AS CLOSED, HD_TICKET.CUSTOM_FIELD_VALUE1 AS CMS,
UNIX_TIMESTAMP(HD_TICKET.TIME_CLOSED)-UNIX_TIMESTAMP(HD_TICKET.CREATED) as DOWNTIME FROM HD_TICKET WHERE (HD_TICKET.HD_QUEUE_ID = 1) AND ( HD_TICKET.CUSTOM_FIELD_VALUE1 LIKE '%Y%') ORDER BY HD_TICKET.CREATED asc
SELECT HD_TICKET.CREATED AS CREATED, HD_TICKET.TIME_OPENED AS OPENED, HD_TICKET.TIME_CLOSED AS CLOSED, HD_TICKET.CUSTOM_FIELD_VALUE1 AS CMS,
UNIX_TIMESTAMP(HD_TICKET.TIME_CLOSED)-UNIX_TIMESTAMP(HD_TICKET.CREATED) as DOWNTIME FROM HD_TICKET WHERE (HD_TICKET.HD_QUEUE_ID = 1) AND ( HD_TICKET.CUSTOM_FIELD_VALUE1 LIKE '%Y%') ORDER BY HD_TICKET.CREATED asc
0 Comments
[ + ] Show comments
Answers (11)
Please log in to answer
Posted by:
airwolf
13 years ago
Posted by:
Lanman145
13 years ago
Posted by:
GillySpy
13 years ago
If we assume your date range is "tickets for your querys that were created in the last 7 days"
if you wanted to know the same results but filters based on a threshold for downtime (which you're measuring in seconds) in your query you would do something like
SELECT HD_TICKET.CREATED AS CREATED, HD_TICKET.TIME_OPENED AS OPENED,HD_TICKET.TIME_CLOSED AS CLOSED, HD_TICKET.CUSTOM_FIELD_VALUE1 AS CMS,
UNIX_TIMESTAMP(HD_TICKET.TIME_CLOSED)-UNIX_TIMESTAMP(HD_TICKET.CREATED)as DOWNTIME FROM HD_TICKET WHERE (HD_TICKET.HD_QUEUE_ID = 1) AND (HD_TICKET.CUSTOM_FIELD_VALUE1 LIKE '%Y%')
and CREATED > DATE_SUB(NOW(), INTERVAL 7 DAY)
ORDER BY HD_TICKET.CREATEDasc
if you wanted to know the same results but filters based on a threshold for downtime (which you're measuring in seconds) in your query you would do something like
SELECT HD_TICKET.CREATED AS CREATED, HD_TICKET.TIME_OPENED AS OPENED,HD_TICKET.TIME_CLOSED AS CLOSED, HD_TICKET.CUSTOM_FIELD_VALUE1 AS CMS,
UNIX_TIMESTAMP(HD_TICKET.TIME_CLOSED)-UNIX_TIMESTAMP(HD_TICKET.CREATED)as DOWNTIME FROM HD_TICKET WHERE (HD_TICKET.HD_QUEUE_ID = 1) AND (HD_TICKET.CUSTOM_FIELD_VALUE1 LIKE '%Y%')
and UNIX_TIMESTAMP(HD_TICKET.TIME_CLOSED)-UNIX_TIMESTAMP(HD_TICKET.CREATED) > 3600 /*>1 hour*/
ORDER BY HD_TICKET.CREATEDasc
Posted by:
Lanman145
13 years ago
Posted by:
GillySpy
13 years ago
Posted by:
Lanman145
13 years ago
Thank you. I also have one more question the sql below I have tried to add the date creating line but i get this error, mysql error: [1052: Column 'CREATED' in where clause is ambiguous] in EXECUTE(
"select
Please let me know where I have gone wrong, Thank you.
SQL code as of now,
select
HD_TICKET.TITLE,
HD_PRIORITY.NAME as PRIORITY,
HD_TICKET.CREATED AS CREATED,
HD_TICKET.TIME_CLOSED AS CLOSED,
HD_CATEGORY.NAME as CATEGORY,
HD_IMPACT.NAME as IMPACT,
ifnull((select FULL_NAME from USER where HD_TICKET.OWNER_ID = USER.ID),' Unassigned') as OWNER,
(select FULL_NAME from USER where HD_TICKET.SUBMITTER_ID = USER.ID) as SUBMITTER,
UNIX_TIMESTAMP(HD_TICKET.TIME_CLOSED)-UNIX_TIMESTAMP(HD_TICKET.CREATED) as DOWNTIME
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_TICKET.HD_QUEUE_ID = 1) AND ( HD_PRIORITY.NAME LIKE '%Critical%') and CREATED > '2011-02-1' and CREATED < '2011-02-15' ORDER BY HD_TICKET.TITLE asc
"select
Please let me know where I have gone wrong, Thank you.
SQL code as of now,
select
HD_TICKET.TITLE,
HD_PRIORITY.NAME as PRIORITY,
HD_TICKET.CREATED AS CREATED,
HD_TICKET.TIME_CLOSED AS CLOSED,
HD_CATEGORY.NAME as CATEGORY,
HD_IMPACT.NAME as IMPACT,
ifnull((select FULL_NAME from USER where HD_TICKET.OWNER_ID = USER.ID),' Unassigned') as OWNER,
(select FULL_NAME from USER where HD_TICKET.SUBMITTER_ID = USER.ID) as SUBMITTER,
UNIX_TIMESTAMP(HD_TICKET.TIME_CLOSED)-UNIX_TIMESTAMP(HD_TICKET.CREATED) as DOWNTIME
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_TICKET.HD_QUEUE_ID = 1) AND ( HD_PRIORITY.NAME LIKE '%Critical%') and CREATED > '2011-02-1' and CREATED < '2011-02-15' ORDER BY HD_TICKET.TITLE asc
Posted by:
GillySpy
13 years ago
Posted by:
Lanman145
13 years ago
Posted by:
Lanman145
13 years ago
Posted by:
GillySpy
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.