• This code works except for the DISTINCT. Please note from earlier posts this is MYSQL.

    Also how can I create a create to run for every month to get a count?

    SELECT DISTINCT ticket.tn, ticket.id, ticket_history.ticket_id, ticket_history.state_id, ticket_history.create_time, MONTH( ticket_history.create_time ) , YEAR( ticket_history.create_time )

    FROM `ticket`

    INNER JOIN ticket_history ON ticket.id = ticket_history.ticket_id

    WHERE ticket_history.state_id =2

    AND freetext7 = 'small'

    AND MONTH( ticket_history.create_time ) =1

    AND YEAR( ticket_history.create_time ) =2014

    ORDER BY `ticket`.`tn` ASC