Derby derailed Middlesbrough's promotion push with a 3-1 home win and first victory in four Championship matches.