query to fill f_ticket