- Edited
I have a few SELECT Query's that I use to get the data I need from osticket for a varity of things.Anyone interested?
I have a few SELECT Query's that I use to get the data I need from osticket for a varity of things.Anyone interested?
Sure.
-Lists tickets for agent in a month that is open SELECT (SELECT CONCAT_WS(' ', `firstname`, `lastname`) AS name FROM ost_staff st WHERE st.staff_id = t.staff_id) AS agent, t.ticket_id, t.number, (SELECT name FROM ost_user u WHERE u.id = t.user_id) AS client, cd.subject, t.created, t.lastupdate FROM ost_ticket tLEFT JOIN ost_ticket__cdata cd ON t.ticket_id = cd.ticket_idLEFT JOIN ost_ticket_status ts ON ts.id = t.status_idWHERE ts.state= 'open' AND DATE_FORMAT(t.created,'%Y-%m') = DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 MONTH), '%Y-%m') GROUP BY number ORDER BY `Agent`-List all Forms values for TicketsSELECT ticket.ticket_id,ticket.number,ticket.dept_id,val.field_id,form.title,formf.label, val.value,ticket.staff_id,user.name, dept.name as dept, status.state as status,ticket.source,ticket.isoverdue,ticket.isanswered,ticket.createdFROM ost_ticket ticketLEFT JOIN ost_ticket_status status ON status.id = ticket.status_id LEFT JOIN ost_user user ON user.id = ticket.user_id LEFT JOIN ost_department dept ON ticket.dept_id=dept.id LEFT JOIN ost_form_entry entry ON ticket.ticket_id = entry.id LEFT JOIN ost_form_entry_values val ON entry.id = val.entry_idLEFT JOIN ost_form form ON form.id = val.entry_idLEFT JOIN ost_form_field formf ON val.field_id = formf.id;
What version is this for?First one : 1054 - Unknown column 't.lastupdate' in 'field list'Second one: 1054 - Unknown column 'dept.name' in 'field list'
Version 1.10rc2I just tried both and it worked fine I have a few more to post.
- open an closed by week for 8 weeks:/* dsTicketsOpenClosed */Select * from( SELECT COUNT(created) AS STATUSCount, 'OPEN' AS Status, FROM_DAYS(TO_DAYS(created) - MOD(TO_DAYS(created) - 2, 7)) AS CALENDARWEEK FROM ost_ticket WHERE FROM_DAYS(TO_DAYS(created) - MOD(TO_DAYS(created) - 2, 7)) BETWEEN DATE_SUB(CURRENT_DATE (), INTERVAL 8 WEEK) AND CURRENT_DATE () AND ost_ticket.topic_id <> 12 and topic_id <> 14 GROUP BY FROM_DAYS(TO_DAYS(created) - MOD(TO_DAYS(created) - 2, 7)) Union SELECT COUNT(closed) AS STATUSCount, 'CLOSED' AS Status, FROM_DAYS(TO_DAYS(closed) - MOD(TO_DAYS(closed) - 2, 7)) AS CALENDARWEEK FROM ost_ticket WHERE FROM_DAYS(TO_DAYS(closed) - MOD(TO_DAYS(closed) - 2, 7)) BETWEEN DATE_SUB(CURRENT_DATE (), INTERVAL 8 WEEK) AND CURRENT_DATE () AND ost_ticket.topic_id <> 12 and topic_id <> 14 GROUP BY FROM_DAYS(TO_DAYS(closed) - MOD(TO_DAYS(closed) - 2, 7))) dataOrder by CALENDARWEEK