[SOLVED] Mysql - display only the last 10 tickets recorded via web?

Moderator: crythias

Locked
amdkryn
Znuny expert
Posts: 187
Joined: 02 Oct 2012, 02:52
Znuny Version: 5.0.27

[SOLVED] Mysql - display only the last 10 tickets recorded via web?

Post by amdkryn »

Can anyone help me in the query below to display only the last 10 tickets registered?

I know nothing about SQL, it was not me who created this query.

SELECT ticket.tn, tht.name FROM `ticket_history` th left join ticket on ticket.id = th.ticket_id left join ticket_history_type tht on tht.id = th.history_type_id WHERE th.history_type_id in (29)

Thanks,
Last edited by amdkryn on 21 May 2015, 17:07, edited 1 time in total.
OTRS version 5.0.27 (With ITSM), Operating System OpenSuse 12 with Mysql.
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Mysql - display only the last 10 tickets recorded via web?

Post by crythias »

Code: Select all

SELECT ticket.tn, tht.name FROM `ticket_history` th left join ticket on ticket.id = th.ticket_id left join ticket_history_type tht on tht.id = th.history_type_id WHERE th.history_type_id in (29)
This selects ticket number and ticket history type from those with WebRequestCustomer

Code: Select all

SELECT ticket.tn, tht.name FROM `ticket_history` th left join ticket on ticket.id = th.ticket_id left join ticket_history_type tht on tht.id = th.history_type_id WHERE th.history_type_id in (29) order by ticket.tn desc limit 10
I'm ordering by ticket number, assuming that is numerically incremental in some way rather than alphanumeric randomized. Otherwise you can

Code: Select all

SELECT ticket.tn, tht.name FROM `ticket_history` th left join ticket on ticket.id = th.ticket_id left join ticket_history_type tht on tht.id = th.history_type_id WHERE th.history_type_id in (29) order by ticket.create_time desc limit 10
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
amdkryn
Znuny expert
Posts: 187
Joined: 02 Oct 2012, 02:52
Znuny Version: 5.0.27

Re: Mysql - display only the last 10 tickets recorded via web?

Post by amdkryn »

Great, thank you.
OTRS version 5.0.27 (With ITSM), Operating System OpenSuse 12 with Mysql.
Locked