Jump to content

Report to track how many tickets are submitted to a department in any given month


Logman

Recommended Posts

15 minutes ago, Logman said:

It's one PHP file but no idea how to use it. Uploaded to modules/addons but nothing shows.

if it's a report, you upload it to /modules/reports - once you refresh the reports page in the browser, you should see it as one of the available reports to use. :idea:

Link to comment
Share on other sites

Cheers Brian. Got the option now but it doesn't seem to work properly. For instance no matter what the date range "Linux Support" always returns seven hundred and something. Oh, just tried one day and still got 191 tickets when he had around 5. Any simple MySQL query I can run to get the stats?

Link to comment
Share on other sites

23 minutes ago, Logman said:

Any simple MySQL query I can run to get the stats?

to get a monthly ticket count, per department, you could use...

SELECT 
DATE_FORMAT(date, "%Y-%m") as Date,
tblticketdepartments.`name` as Department,
Count(*) as Count
FROM
tbltickets
INNER JOIN tblticketdepartments ON tbltickets.did = tblticketdepartments.id
GROUP BY Department, Date
ORDER BY date ASC

in any months not listed, you can assume that no tickets were created for any department.

if you just need it for a specific month, e.g June 2018

SELECT 
DATE_FORMAT(date, "%Y-%m") as Date,
tblticketdepartments.`name` as Department,
Count(*) as Count
FROM
tbltickets
INNER JOIN tblticketdepartments ON tbltickets.did = tblticketdepartments.id
WHERE
DATE_FORMAT(date, "%Y-%m") = '2018-06'
GROUP BY Department, Date
ORDER BY date ASC

 

Link to comment
Share on other sites

Thanks Brian. That gives me an output like this:

eec3561b07629a46f240c6bba6468122.png

Each row can't be a day as this is for June and only 10 days in. Also we have 3 departments in total and the query seems to be pulling from the first default department. Ideally I'd like to see a printout of just the number of tickets in each department (rather than a row per ticket). Don't suppose you have that query up your sleeve somewhere? :)

Edited by Logman
Link to comment
Share on other sites

6 minutes ago, Logman said:

Each row can't be a day as this is for June and only 10 days in.

i'm assuming you can get more than one ticket per day! :smile2:

6 minutes ago, Logman said:

Also we have 3 departments in total and the query seems to be pulling from the first default department.

it shouldn't be.... my guess is that if you scrolled through the results, you'd find other departments listed.

6 minutes ago, Logman said:

Ideally I'd like to see a printout of just the number of tickets in each department (rather than a row per ticket). Don't suppose you have that query up your sleeve somewhere?

there was an error in the "group by" option - try using...

SELECT 
DATE_FORMAT(date, "%Y-%m") as Date,
tblticketdepartments.`name` as Department,
Count(*) as Count
FROM
tbltickets
INNER JOIN tblticketdepartments ON tbltickets.did = tblticketdepartments.id
GROUP BY DATE_FORMAT(date, "%Y-%m"),Department
ORDER BY date ASC

this is what i'm seeing when I run this on a v7.5.1 dev...

S0c9ILp.png

Link to comment
Share on other sites

Great, so modified for May:

SELECT 
DATE_FORMAT(date, "%Y-%m") as Date,
tblticketdepartments.`name` as Department,
Count(*) as Count
FROM
tbltickets
INNER JOIN tblticketdepartments ON tbltickets.did = tblticketdepartments.id
GROUP BY DATE_FORMAT(date, "%Y-%m") = '2018-06',Department
ORDER BY date ASC

I guess that is accurate, seems about right. Not sure why those first 3 rows are outputted though.

f23ee50467719dbf75534d4c5d7cd217.png

 

Edited by Logman
Link to comment
Share on other sites

18 minutes ago, Logman said:

Not sure why those first 3 rows are outputted though.

you have a slightly kinky "group by" statement that should be split off into a "where"...

SELECT 
DATE_FORMAT(date, "%Y-%m") as Date,
tblticketdepartments.`name` as Department,
Count(*) as Count
FROM tbltickets
INNER JOIN tblticketdepartments ON tbltickets.did = tblticketdepartments.id
WHERE DATE_FORMAT(date, "%Y-%m") = '2018-05'
GROUP BY DATE_FORMAT(date, "%Y-%m"),Department

hopefully, that will now give you a count for May only... if it's for one month only, you won't need the date sort because they should all have the same month.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated