-- Database schema
| location : locationID [ INTEGER ] primary_key , locationcity [ TEXT ] , address [ TEXT ] , state [ TEXT ] , zipcode [ INTEGER ] , officephone [ TEXT ] | position : positionID [ INTEGER ] primary_key , positiontitle [ TEXT ] , educationrequired [ TEXT ] , minsalary [ TEXT ] , maxsalary [ TEXT ] | employee : ssn [ TEXT ] primary_key , lastname [ TEXT ] , firstname [ TEXT ] , hiredate [ TEXT ] , salary [ TEXT ] , gender [ TEXT ] , performance [ TEXT ] , positionID [ INTEGER ] employee.positionID = position.positionID , locationID [ INTEGER ] employee.locationID = location.locationID |
-- -- What is the average salary of the employees who work as a Trainee?

SELECT AVG(CAST(REPLACE(SUBSTR(T1.salary, 4), ',', '') AS REAL)) AS avg FROM employee AS T1  INNER JOIN position AS T2  ON T1.positionID = T2.positionID WHERE T2.positiontitle = 'Trainee';