Database schema:

CREATE TABLE donations (
	donationid TEXT NOT NULL -- example: ['000000a91a14ed37bef82e125c102e77', '000013be53ed7382ed5d5975eb86eb85'],
	projectid TEXT -- example: ['ffffac55ee02a49d1abc87ba6fc61135', 'ffff97ed93720407d70a2787475932b0'],
	donor_acctid TEXT -- example: ['22cbc920c9b5fa08dfb331422f5926b5', '521f1830a77c9dbbf8119d99c6206a16'],
	donor_city TEXT -- example: ['Peachtree City', 'Rockville'],
	donor_state TEXT -- example: ['GA', 'MD'],
	donor_zip TEXT -- example: ['30269', '20853'],
	is_teacher_acct TEXT -- example: ['f', 't'],
	donation_timestamp DATETIME -- example: ['2011-11-04 07:54:21.552000', '2011-08-25 14:27:34.807000'],
	donation_to_project REAL -- example: ['26.83', '42.5'],
	donation_optional_support REAL -- example: ['7.5', '4.73'],
	donation_total REAL -- example: ['31.56', '50.0'],
	dollar_amount TEXT -- example: ['under_10', '10_to_100'],
	donation_included_optional_support TEXT -- example: ['f', 't'],
	payment_method TEXT -- example: ['no_cash_received', 'creditcard'],
	payment_included_acct_credit TEXT -- example: ['f', 't'],
	payment_included_campaign_gift_card TEXT -- example: ['f', 't'],
	payment_included_web_purchased_gift_card TEXT -- example: ['f', 't'],
	payment_was_promo_matched TEXT -- example: ['f', 't'],
	via_giving_page TEXT -- example: ['f', 't'],
	for_honoree TEXT -- example: ['f', 't'],
	donation_message TEXT -- example: ['I gave to this project because I support the effor', 'I donated because I want to support kids in Georgi'],
	PRIMARY KEY (donationid), 
	CONSTRAINT fk_donations_projects FOREIGN KEY(projectid) REFERENCES projects (projectid)
)


CREATE TABLE essays (
	projectid TEXT -- example: ['ffffac55ee02a49d1abc87ba6fc61135', 'ffffc4f85b60efc5b52347df489d0238'],
	teacher_acctid TEXT -- example: ['947066d0af47e0566f334566553dd6a6', 'c24011b20fc161ed02248e85beb59a90'],
	title TEXT -- example: ["Recording Rockin' Readers", 'iMath'],
	short_description TEXT -- example: ['It is imperative that teachers bring technology in', 'Can you imagine having to translate everything you'],
	need_statement TEXT -- example: ['My students need four iPods.', 'My students need a camcorder. '],
	essay TEXT -- example: ['I am a fourth year fifth grade math teacher. The s', 'Can you imagine having to translate everything you']
)


CREATE TABLE projects (
	projectid TEXT NOT NULL -- example: ['00002bff514104264a6b798356fdd893', '00001ccc0e81598c4bd86bacb94d7acb'],
	teacher_acctid TEXT -- example: ['864eb466462bf704bf7a16a585ef296a', '42d43fa6f37314365d08692e08680973'],
	schoolid TEXT -- example: ['c0e6ce89b244764085691a1b8e28cb81', 'd711e47810900c96f26a5d0be30c446d'],
	school_ncesid TEXT -- example: ['063627006187', '483702008193'],
	school_latitude REAL -- example: ['36.57634', '32.911179'],
	school_longitude REAL -- example: ['-119.608713', '-96.72364'],
	school_city TEXT -- example: ['Dallas', 'Selma'],
	school_state TEXT -- example: ['TX', 'CA'],
	school_zip INTEGER -- example: ['93662', '75243'],
	school_metro TEXT -- example: ['rural', 'urban'],
	school_district TEXT -- example: ['Selma Unified Sch District', 'Richardson Ind School District'],
	school_county TEXT -- example: ['Dallas', 'Fresno'],
	school_charter TEXT -- example: ['f', 't'],
	school_magnet TEXT -- example: ['f', 't'],
	school_year_round TEXT -- example: ['f', 't'],
	school_nlns TEXT -- example: ['f', 't'],
	school_kipp TEXT -- example: ['f', 't'],
	school_charter_ready_promise TEXT -- example: ['f', 't'],
	teacher_prefix TEXT -- example: ['Mrs.', 'Mr.'],
	teacher_teach_for_america TEXT -- example: ['f', 't'],
	teacher_ny_teaching_fellow TEXT -- example: ['f', 't'],
	primary_focus_subject TEXT -- example: ['Literacy', 'Literature & Writing'],
	primary_focus_area TEXT -- example: ['Literacy & Language', 'History & Civics'],
	secondary_focus_subject TEXT -- example: ['College & Career Prep', 'ESL'],
	secondary_focus_area TEXT -- example: ['Literacy & Language', 'Applied Learning'],
	resource_type TEXT -- example: ['Technology', 'Books'],
	poverty_level TEXT -- example: ['highest poverty', 'high poverty'],
	grade_level TEXT -- example: ['Grades PreK-2', 'Grades 6-8'],
	fulfillment_labor_materials REAL -- example: ['35.0', '30.0'],
	total_price_excluding_optional_support REAL -- example: ['296.47', '555.81'],
	total_price_including_optional_support REAL -- example: ['653.89', '348.79'],
	students_reached INTEGER -- example: ['22', '32'],
	eligible_double_your_impact_match TEXT -- example: ['f', 't'],
	eligible_almost_home_match TEXT -- example: ['f', 't'],
	date_posted DATE -- example: ['2014-05-12', '2014-05-11'],
	PRIMARY KEY (projectid)
)


CREATE TABLE resources (
	resourceid TEXT NOT NULL -- example: ['0000037fecc4461faf0e49328ae66661', '0000046b69c683354ca46b30db5c558e'],
	projectid TEXT -- example: ['ffffac55ee02a49d1abc87ba6fc61135', 'ffffc4f85b60efc5b52347df489d0238'],
	vendorid INTEGER -- example: ['430', '82'],
	vendor_name TEXT -- example: ['Woodwind and Brasswind', 'Best Buy for Business'],
	project_resource_type TEXT -- example: ['Supplies', 'Technology'],
	item_name TEXT -- example: ['iPod nano 4th Gen 8GB (Black)', 'Sony bloggie MHS-FS1 - camcorder - internal flash '],
	item_number TEXT -- example: ['249995.001', 'BB11216668'],
	item_unit_price REAL -- example: ['148.0', '149.0'],
	item_quantity INTEGER -- example: ['1', '4'],
	PRIMARY KEY (resourceid), 
	CONSTRAINT fk_resources_projects FOREIGN KEY(projectid) REFERENCES projects (projectid)
)

Question: From which state do the 5 biggest donor, who gave the highest cost of optional support, come from? List their donor_acctid and calculate for their average cost of optional support for every donations they make and identtify the project's type of resource to which they gave the hightest optional support.
Evidence: which state refers to school_state; highest cost of optional support refers to max(donation_optional_support); average cost of optional support = avg(donation_optional_support)

SQL:
SELECT T1.school_state, T2.donor_acctid, AVG(T2.donation_optional_support), T1.resource_type FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid ORDER BY T2.donation_optional_support DESC LIMIT 5