Database schema:

CREATE TABLE "constructorResults" (
	"constructorResultsId" INTEGER -- constructor Results Id, example: ['2', '1'],
	"raceId" INTEGER DEFAULT 0 NOT NULL -- race Id, example: ['18', '19'],
	"constructorId" INTEGER DEFAULT 0 NOT NULL -- constructor Id, example: ['2', '1'],
	points REAL -- example: ['14.0', '8.0'],
	status TEXT -- example: ['D'],
	PRIMARY KEY ("constructorResultsId"), 
	CONSTRAINT fk_constructorresults_races FOREIGN KEY("raceId") REFERENCES races ("raceId"),
	CONSTRAINT fk_constructorresults_constructors FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId")
)


CREATE TABLE "constructorStandings" (
	"constructorStandingsId" INTEGER -- constructor Standings Id, example: ['2', '1'],
	"raceId" INTEGER DEFAULT 0 NOT NULL -- race id, example: ['18', '19'],
	"constructorId" INTEGER DEFAULT 0 NOT NULL -- constructor id, example: ['2', '1'],
	points REAL DEFAULT 0 NOT NULL -- example: ['14.0', '8.0'],
	position INTEGER -- example: ['1', '3'],
	"positionText" TEXT -- position text, example: ['1', '3'],
	wins INTEGER DEFAULT 0 NOT NULL -- example: ['0', '1'],
	PRIMARY KEY ("constructorStandingsId"), 
	CONSTRAINT fk_constructorstandings_races FOREIGN KEY("raceId") REFERENCES races ("raceId"),
	CONSTRAINT fk_constructorstandings_constructors FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId")
)


CREATE TABLE "driverStandings" (
	"driverStandingsId" INTEGER -- driver Standings Id, example: ['2', '1'],
	"raceId" INTEGER DEFAULT 0 NOT NULL -- constructor Reference name, example: ['18', '19'],
	"driverId" INTEGER DEFAULT 0 NOT NULL -- example: ['2', '1'],
	points REAL DEFAULT 0 NOT NULL -- example: ['10.0', '8.0'],
	position INTEGER -- example: ['2', '1'],
	"positionText" TEXT -- position text, example: ['2', '1'],
	wins INTEGER DEFAULT 0 NOT NULL -- example: ['0', '1'],
	PRIMARY KEY ("driverStandingsId"), 
	CONSTRAINT fk_driverstandings_races FOREIGN KEY("raceId") REFERENCES races ("raceId"),
	CONSTRAINT fk_driverstandings_drivers FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)


CREATE TABLE "lapTimes" (
	"raceId" INTEGER NOT NULL -- race ID, example: ['2', '1'],
	"driverId" INTEGER NOT NULL -- driver ID, example: ['2', '1'],
	lap INTEGER NOT NULL -- example: ['2', '1'],
	position INTEGER -- example: ['13', '12'],
	time TEXT -- example: ['1:49.088', '1:33.740'],
	milliseconds INTEGER -- example: ['109088', '93740'],
	PRIMARY KEY ("raceId", "driverId", lap), 
	CONSTRAINT fk_laptimes_races FOREIGN KEY("raceId") REFERENCES races ("raceId"),
	CONSTRAINT fk_laptimes_drivers FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)


CREATE TABLE "pitStops" (
	"raceId" INTEGER NOT NULL -- race ID, example: ['841', '842'],
	"driverId" INTEGER NOT NULL -- driver ID, example: ['2', '1'],
	stop INTEGER NOT NULL -- example: ['2', '1'],
	lap INTEGER NOT NULL -- example: ['16', '36'],
	time TEXT NOT NULL -- example: ['17:28:24', '17:59:29'],
	duration TEXT -- example: ['23.199', '23.227'],
	milliseconds INTEGER -- example: ['23227', '23199'],
	PRIMARY KEY ("raceId", "driverId", stop), 
	CONSTRAINT fk_pitstops_races FOREIGN KEY("raceId") REFERENCES races ("raceId"),
	CONSTRAINT fk_pitstops_drivers FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)


CREATE TABLE circuits (
	"circuitId" INTEGER -- circuit Id, example: ['23', '61'],
	"circuitRef" TEXT DEFAULT '' NOT NULL -- circuit reference name, example: ['sepang', 'bahrain'],
	name TEXT DEFAULT '' NOT NULL -- example: ['Bahrain International Circuit', 'Sepang International Circuit'],
	location TEXT -- example: ['Kuala Lumpur', 'Sakhir'],
	country TEXT -- example: ['Malaysia', 'Bahrain'],
	lat REAL -- latitude, example: ['26.0325', '2.76083'],
	lng REAL -- longitude, example: ['50.5106', '101.738'],
	alt INTEGER, 
	url TEXT DEFAULT '' NOT NULL -- example: ['http://en.wikipedia.org/wiki/AVUS', 'http://en.wikipedia.org/wiki/A1-Ring'],
	PRIMARY KEY ("circuitId")
)


CREATE TABLE constructors (
	"constructorId" INTEGER -- constructor Id, example: ['39', '147'],
	"constructorRef" TEXT DEFAULT '' NOT NULL -- Constructor Reference name, example: ['bmw_sauber', 'mclaren'],
	name TEXT DEFAULT '' NOT NULL -- example: ['AFM', 'AGS'],
	nationality TEXT -- example: ['British', 'German'],
	url TEXT DEFAULT '' NOT NULL -- example: ['http://en.wikipedia.org/wiki/McLaren', 'http://en.wikipedia.org/wiki/BMW_Sauber'],
	PRIMARY KEY ("constructorId")
)


CREATE TABLE drivers (
	"driverId" INTEGER -- driver ID, example: ['452', '625'],
	"driverRef" TEXT DEFAULT '' NOT NULL -- driver reference name, example: ['heidfeld', 'hamilton'],
	number INTEGER -- example: ['6', '44'],
	code TEXT -- example: ['HEI', 'HAM'],
	forename TEXT DEFAULT '' NOT NULL -- example: ['Lewis', 'Nick'],
	surname TEXT DEFAULT '' NOT NULL -- example: ['Heidfeld', 'Hamilton'],
	dob DATE -- date of birth, example: ['1977-05-10', '1985-01-07'],
	nationality TEXT -- example: ['British', 'German'],
	url TEXT DEFAULT '' NOT NULL -- example: ['', 'http://en.wikipedia.org/wiki/%C3%89lie_Bayol'],
	PRIMARY KEY ("driverId")
)


CREATE TABLE qualifying (
	"qualifyId" INTEGER -- qualify Id, example: ['2', '1'],
	"raceId" INTEGER DEFAULT 0 NOT NULL -- race Id, example: ['18', '19'],
	"driverId" INTEGER DEFAULT 0 NOT NULL -- driver Id, example: ['9', '1'],
	"constructorId" INTEGER DEFAULT 0 NOT NULL -- constructor id, example: ['2', '1'],
	number INTEGER DEFAULT 0 NOT NULL -- example: ['22', '4'],
	position INTEGER -- example: ['2', '1'],
	q1 TEXT -- qualifying 1, example: ['1:26.103', '1:26.572'],
	q2 TEXT -- qualifying 2, example: ['1:25.187', '1:25.315'],
	q3 TEXT -- qualifying 3, example: ['1:26.714', '1:26.869'],
	PRIMARY KEY ("qualifyId"), 
	CONSTRAINT fk_qualifying_races FOREIGN KEY("raceId") REFERENCES races ("raceId"),
	CONSTRAINT fk_qualifying_drivers FOREIGN KEY("driverId") REFERENCES drivers ("driverId"),
	CONSTRAINT fk_qualifying_constructors FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId")
)


CREATE TABLE races (
	"raceId" INTEGER -- race ID, example: ['837', '833'],
	year INTEGER DEFAULT 0 NOT NULL -- example: ['2008', '2009'],
	round INTEGER DEFAULT 0 NOT NULL -- example: ['2', '1'],
	"circuitId" INTEGER DEFAULT 0 NOT NULL -- Circuit Id, example: ['2', '1'],
	name TEXT DEFAULT '' NOT NULL -- example: ['Australian Grand Prix', 'Malaysian Grand Prix'],
	date DATE DEFAULT '0000-00-00' NOT NULL -- example: ['2009-04-05', '2009-03-29'],
	time TEXT -- example: ['06:00:00', '09:00:00'],
	url TEXT -- example: ['http://en.wikipedia.org/wiki/1950_British_Grand_Pr', 'http://en.wikipedia.org/wiki/1950_Belgian_Grand_Pr'],
	PRIMARY KEY ("raceId"), 
	CONSTRAINT fk_races_seasons FOREIGN KEY(year) REFERENCES seasons (year),
	CONSTRAINT fk_races_circuits FOREIGN KEY("circuitId") REFERENCES circuits ("circuitId"),
	UNIQUE (url)
)


CREATE TABLE results (
	"resultId" INTEGER -- Result ID, example: ['2', '1'],
	"raceId" INTEGER DEFAULT 0 NOT NULL -- race ID, example: ['18', '19'],
	"driverId" INTEGER DEFAULT 0 NOT NULL -- driver ID, example: ['2', '1'],
	"constructorId" INTEGER DEFAULT 0 NOT NULL -- constructor Id, example: ['2', '1'],
	number INTEGER -- example: ['22', '3'],
	grid INTEGER DEFAULT 0 NOT NULL -- example: ['5', '1'],
	position INTEGER -- example: ['2', '1'],
	"positionText" TEXT DEFAULT '' NOT NULL -- position text, example: ['2', '1'],
	"positionOrder" INTEGER DEFAULT 0 NOT NULL -- position order, example: ['2', '1'],
	points REAL DEFAULT 0 NOT NULL -- example: ['10.0', '8.0'],
	laps INTEGER DEFAULT 0 NOT NULL -- example: ['58', '57'],
	time TEXT -- example: ['1:34:50.616', '+5.478'],
	milliseconds INTEGER -- example: ['5696094', '5690616'],
	"fastestLap" INTEGER -- fastest lap, example: ['39', '41'],
	rank INTEGER DEFAULT 0 -- example: ['2', '3'],
	"fastestLapTime" TEXT -- fastest Lap Time, example: ['1:27.452', '1:27.739'],
	"fastestLapSpeed" TEXT -- fastest Lap Speed, example: ['218.300', '217.586'],
	"statusId" INTEGER DEFAULT 0 NOT NULL -- status Id, example: ['1', '11'],
	PRIMARY KEY ("resultId"), 
	CONSTRAINT fk_results_races FOREIGN KEY("raceId") REFERENCES races ("raceId"),
	CONSTRAINT fk_results_drivers FOREIGN KEY("driverId") REFERENCES drivers ("driverId"),
	CONSTRAINT fk_results_constructors FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
	CONSTRAINT fk_results_status FOREIGN KEY("statusId") REFERENCES status ("statusId")
)


CREATE TABLE seasons (
	year INTEGER DEFAULT 0 NOT NULL -- race ID, example: ['1950', '1951'],
	url TEXT DEFAULT '' NOT NULL -- example: ['http://en.wikipedia.org/wiki/1950_Formula_One_seas', 'http://en.wikipedia.org/wiki/1951_Formula_One_seas'],
	PRIMARY KEY (year)
)


CREATE TABLE status (
	"statusId" INTEGER -- status ID, example: ['2', '1'],
	status TEXT DEFAULT '' NOT NULL -- example: ['Disqualified', 'Finished'],
	PRIMARY KEY ("statusId")
)

Question: What was the longest time that Lewis Hamilton had spent at a pit stop?
Evidence: longest time refes to MAX(duration);

SQL:
SELECT T1.duration FROM pitStops AS T1 INNER JOIN drivers AS T2 on T1.driverId = T2.driverId WHERE T2.forename = 'Lewis' AND T2.surname = 'Hamilton' ORDER BY T1.duration DESC LIMIT 1