Write SQL query to solve given problem: Among the students with a gpa of 3.1 to 3.7, how many of them are undergraduate students?. Keep the solution inside sql tag ```sql [SQL-Query] ```
SELECT COUNT(student_id) FROM student WHERE gpa BETWEEN 3.1 AND 3.7 AND type = 'UG'