ticket_view's sql