Database schema:

CREATE TABLE employee (
	ssn TEXT -- example: ['000-01-0000', '000-02-2222'],
	lastname TEXT -- example: ['Adams', 'Milgrom'],
	firstname TEXT -- example: ['Sandy', 'Patricia'],
	hiredate TEXT -- example: ['10/1/04', '1/15/01'],
	salary TEXT -- example: ['US$19,500.00', 'US$57,500.00'],
	gender TEXT -- example: ['M', 'F'],
	performance TEXT -- example: ['Good', 'Average'],
	"positionID" INTEGER -- example: ['2', '3'],
	"locationID" INTEGER -- example: ['2', '1'],
	PRIMARY KEY (ssn), 
	CONSTRAINT fk_employee_location FOREIGN KEY("locationID") REFERENCES location ("locationID"),
	CONSTRAINT fk_employee_position FOREIGN KEY("positionID") REFERENCES position ("positionID")
)


CREATE TABLE location (
	"locationID" INTEGER -- example: ['2', '1'],
	locationcity TEXT -- example: ['Boston', 'Atlanta'],
	address TEXT -- example: ['3 Commons Blvd', '450 Peachtree Rd'],
	state TEXT -- example: ['MA', 'GA'],
	zipcode INTEGER -- example: ['30316', '2190'],
	officephone TEXT -- example: ['(404)333-5555', '(617)123-4444'],
	PRIMARY KEY ("locationID")
)


CREATE TABLE position (
	"positionID" INTEGER -- example: ['2', '1'],
	positiontitle TEXT -- example: ['Account Representative', 'Manager'],
	educationrequired TEXT -- example: ['2 year degree', '4 year degree'],
	minsalary TEXT -- example: ['US$25,000.00', 'US$50,000.00'],
	maxsalary TEXT -- example: ['US$75,000.00', 'US$150,000.00'],
	PRIMARY KEY ("positionID")
)

Question: What is the average salary of the employees who work as a Trainee?
Evidence: average = DIVIDE( SUM(salary), COUNT(positiontitle) where positiontitle = 'Trainee'; Trainee is a position title

SQL:
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'