My boss wants a report with the total tickets per month for the year and for the life of me I have no idea how to manage that.  Has anyone had to do this before?  No need for categories or anything.  Simply raw numbers.

2 Comments   [ + ] Show Comments

Comments

  • Could someone help modify this report so it will display it by queue as well?
  • How can I take the SQL code for this option above:

    Ticket Count by Owner (Current Year)

    and have it changed to:

    Ticket County by Category (Current Year)

    ?

    Every example I have found with suggestions to make changes to the code keeps resulting in SQL errors that the column doesn't exist. Any help would be greatly appreciated.
Please log in to comment

Community Chosen Answer

1

Here's the main one I use, with owners listed.  The second one is a tweak that does not include the owners column.  If you need help tweaking it any further, just let me know.

Hope that helps!

John

________________________________

*Title*
Ticket Count by Owner (Current Year)

*Report Category*
Helpdesk (Custom)

*Description*
Lists ticket count by owner and status by month for current year.

*SQL Select Statement*
SELECT OPEN.OWNER, OPEN.MONTH, OPEN.YEAR, Coalesce(OPEN.OPEN, 0) AS OPENED, Coalesce(CLOSED.CLOSED, 0) AS CLOSED
FROM (SELECT Coalesce(U.USER_NAME, 'NO OWNER ASSIGNED') AS OWNER, date_format(T.CREATED, '%M') AS MONTH, YEAR (T.CREATED) AS YEAR, COUNT(*) AS OPEN
FROM HD_TICKET T                
LEFT JOIN USER U ON T.OWNER_ID = U.ID
GROUP BY OWNER_ID, MONTH, YEAR        
ORDER BY YEAR, MONTH) OPEN       
LEFT JOIN (SELECT Coalesce(U.USER_NAME, 'NO OWNER ASSIGNED') AS OWNER, date_format(T.TIME_CLOSED, '%M') AS MONTH, YEAR (T.TIME_CLOSED) AS YEAR, COUNT(*) AS CLOSED
FROM HD_TICKET T                    
JOIN HD_STATUS S ON HD_STATUS_ID=S.ID and S.STATE ='Closed'
LEFT JOIN USER U ON T.OWNER_ID = U.ID
GROUP BY OWNER_ID, MONTH, YEAR
ORDER BY YEAR, MONTH) CLOSED
ON (OPEN.MONTH = CLOSED.MONTH AND OPEN.YEAR = CLOSED.YEAR AND OPEN.OWNER = CLOSED.OWNER )
WHERE OPEN.YEAR = date_format(curdate(), '%Y')
ORDER BY YEAR desc, str_to_date(OPEN.MONTH,'%M') desc, OWNER

*Break on Columns*
MONTH

________________________________

*Title*
Ticket Count (Current Year)

*Report Category*
Helpdesk (Custom)

*Description*
Lists ticket count by status by month for current year.

*SQL Select Statement*
SELECT OPEN.MONTH, OPEN.YEAR, Coalesce(OPEN.OPEN, 0) AS OPENED, Coalesce(CLOSED.CLOSED, 0) AS CLOSED
FROM (SELECT date_format(T.CREATED, '%M') AS MONTH, YEAR (T.CREATED) AS YEAR, COUNT(*) AS OPEN
FROM HD_TICKET T
GROUP BY MONTH, YEAR
ORDER BY YEAR, MONTH) OPEN
LEFT JOIN (SELECT date_format(T.TIME_CLOSED, '%M') AS MONTH, YEAR (T.TIME_CLOSED) AS YEAR, COUNT(*) AS CLOSED
FROM HD_TICKET T
JOIN HD_STATUS S ON HD_STATUS_ID=S.ID and S.STATE ='Closed'
GROUP BY MONTH, YEAR
ORDER BY YEAR, MONTH) CLOSED
ON (OPEN.MONTH = CLOSED.MONTH AND OPEN.YEAR = CLOSED.YEAR)
WHERE OPEN.YEAR = date_format(curdate(), '%Y')
ORDER BY YEAR desc, str_to_date(OPEN.MONTH,'%M') desc

Answered 12/07/2012 by: jverbosk
Red Belt

  • Is there a way to take the ability to sort by month you have above, and add it to my own report I made with the wizard, replacing the interval section?
  • Yes, it should be possible, but some things (like the date formats) may need to be tweaked to get things working.

    I'm providing the baseline and simplified versions of the reports below, to hopefully make transplanting what you want a bit easier. But if this is still not clear, try running the queries below and compare the T.CREATED value's format against what you get for MONTH and YEAR values. Then research the following date functions to get a better understanding of what they are doing and how they work:

    date_format()
    str_to_date()
    year()

    http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
    ____________________________________________________

    baseline version without any date functions

    select T.CREATED,
    count(*) as OPEN
    from HD_TICKET T
    order by T.CREATED
    ____________________________________________________

    Simplified version - only tickets with an Open status

    select date_format(T.CREATED, '%M') as MONTH,
    YEAR(T.CREATED) as YEAR,
    count(*) as OPEN
    from HD_TICKET T
    group by MONTH, YEAR
    order by YEAR desc, str_to_date(MONTH,'%M') desc
    ____________________________________________________

    Simplified version - only tickets with an Open status for the current year

    select date_format(T.CREATED, '%M') as MONTH,
    YEAR(T.CREATED) as YEAR,
    count(*) as OPEN
    from HD_TICKET T
    where YEAR(T.CREATED) = date_format(curdate(), '%Y')
    group by MONTH, YEAR
    order by YEAR desc, str_to_date(MONTH,'%M') desc
    ____________________________________________________

    Hope that helps!

    John
Please log in to comment

Answers

0

I think this thread can help get you started. 

http://www.itninja.com/question/monthly-help-desk-ticket-report

Answered 12/07/2012 by: jdornan
Red Belt

Please log in to comment
0
How would I take the Ticket Count by Owner (This Year) query and change it to a Ticket Count by Category (This Year) query? I have spent hours trying to get this to work after reviewing dozens of other examples with no luck. Thank you for any help you can provide.
Answered 02/29/2016 by: afort
White Belt

Please log in to comment
0
Could someone help me modify this to separate the opened/closed by queue as well? 
Answered 12/18/2014 by: jensenfox
White Belt

Please log in to comment
Answer this question or Comment on this question for clarity