Database schema:

CREATE TABLE institution_details (
	unitid INTEGER -- example: ['100663', '100654'],
	chronname TEXT -- example: ['University of Alabama at Birmingham', 'Alabama A&M University'],
	city TEXT -- example: ['Birmingham', 'Normal'],
	state TEXT -- example: ['Alaska', 'Alabama'],
	level TEXT -- example: ['2-year', '4-year'],
	control TEXT -- example: ['Public', 'Private not-for-profit'],
	basic TEXT -- example: ['Masters Colleges and Universities--larger programs', 'Research Universities--very high research activity'],
	hbcu TEXT -- example: ['NULL', 'X'],
	flagship TEXT -- example: ['NULL', 'X'],
	long_x REAL -- example: ['-86.80917', '-86.568502'],
	lat_y REAL -- example: ['33.50223', '34.783368'],
	site TEXT -- example: ['www.uab.edu', 'www.aamu.edu/'],
	student_count INTEGER -- example: ['4051', '11502'],
	awards_per_value REAL -- example: ['14.2', '20.9'],
	awards_per_state_value REAL -- example: ['18.8', '17.8'],
	awards_per_natl_value REAL -- example: ['21.5', '22.5'],
	exp_award_value INTEGER -- example: ['105331', '136546'],
	exp_award_state_value INTEGER -- example: ['75743', '92268'],
	exp_award_natl_value INTEGER -- example: ['66436', '101725'],
	exp_award_percentile INTEGER -- example: ['97', '90'],
	ft_pct REAL -- example: ['93.8', '72.7'],
	fte_value INTEGER -- example: ['3906', '10032'],
	fte_percentile INTEGER -- example: ['33', '67'],
	med_sat_value TEXT -- example: ['1146', '823'],
	med_sat_percentile TEXT -- example: ['0', '84'],
	aid_value INTEGER -- example: ['6088', '7142'],
	aid_percentile INTEGER -- example: ['50', '72'],
	endow_value TEXT -- example: ['24136', 'NULL'],
	endow_percentile TEXT -- example: ['93', 'NULL'],
	grad_100_value REAL -- example: ['10.0', '29.4'],
	grad_100_percentile INTEGER -- example: ['15', '67'],
	grad_150_value REAL -- example: ['53.5', '29.1'],
	grad_150_percentile INTEGER -- example: ['14', '66'],
	pell_value REAL -- example: ['71.2', '35.1'],
	pell_percentile INTEGER -- example: ['39', '98'],
	retain_value REAL -- example: ['80.2', '63.1'],
	retain_percentile INTEGER -- example: ['17', '70'],
	ft_fac_value REAL -- example: ['82.8', '92.4'],
	ft_fac_percentile INTEGER -- example: ['98', '89'],
	vsa_year TEXT -- example: ['2010', '2011'],
	vsa_grad_after4_first TEXT -- example: ['22.3', '14.7'],
	vsa_grad_elsewhere_after4_first TEXT -- example: ['2', '2.9'],
	vsa_enroll_after4_first TEXT -- example: ['34.2', '36.5'],
	vsa_enroll_elsewhere_after4_first TEXT -- example: ['16.1', '19.2'],
	vsa_grad_after6_first TEXT -- example: ['33', '42.6'],
	vsa_grad_elsewhere_after6_first TEXT -- example: ['10.5', '5.3'],
	vsa_enroll_after6_first TEXT -- example: ['12.5', '7.9'],
	vsa_enroll_elsewhere_after6_first TEXT -- example: ['13.1', '14.6'],
	vsa_grad_after4_transfer TEXT -- example: ['NULL', '15.7'],
	vsa_grad_elsewhere_after4_transfer TEXT -- example: ['NULL', '1.5'],
	vsa_enroll_after4_transfer TEXT -- example: ['NULL', '40.9'],
	vsa_enroll_elsewhere_after4_transfer TEXT -- example: ['NULL', '17.2'],
	vsa_grad_after6_transfer TEXT -- example: ['NULL', '36.4'],
	vsa_grad_elsewhere_after6_transfer TEXT -- example: ['NULL', '5.6'],
	vsa_enroll_after6_transfer TEXT -- example: ['NULL', '17.2'],
	vsa_enroll_elsewhere_after6_transfer TEXT -- example: ['11.1', 'NULL'],
	similar TEXT -- example: ['196060|180461|201885|145600|209542|236939|126818|2', '232937|100724|405997|113607|139533|144005|228501|1'],
	state_sector_ct INTEGER -- example: ['16', '13'],
	carnegie_ct INTEGER -- example: ['386', '106'],
	counted_pct TEXT -- example: ['56.0|07', '99.7|07'],
	nicknames TEXT -- example: ['NULL', 'UAB'],
	cohort_size INTEGER -- example: ['882', '1376'],
	PRIMARY KEY (unitid)
)


CREATE TABLE institution_grads (
	unitid INTEGER -- example: ['101028', '100760'],
	year INTEGER -- example: ['2012', '2011'],
	gender TEXT -- example: ['B', 'M'],
	race TEXT -- example: ['X', 'W'],
	cohort TEXT -- example: ['4y other', '2y all'],
	grad_cohort TEXT -- example: ['446', '185'],
	grad_100 TEXT -- example: ['NULL', '73'],
	grad_150 TEXT -- example: ['105', '40'],
	grad_100_rate TEXT -- example: ['16.4', 'NULL'],
	grad_150_rate TEXT -- example: ['21.6', '23.5'],
	CONSTRAINT fk_institution_grads_institution_details FOREIGN KEY(unitid) REFERENCES institution_details (unitid)
)


CREATE TABLE state_sector_details (
	stateid INTEGER -- example: ['0', '1'],
	state TEXT -- example: ['Alabama', 'United States'],
	state_post TEXT -- example: ['U.S.', 'Ala.'],
	level TEXT -- example: ['2-year', '4-year'],
	control TEXT -- example: ['Private for-profit', 'Private not-for-profit'],
	schools_count INTEGER -- example: ['1180', '632'],
	counted_pct TEXT -- example: ['NULL', '61'],
	awards_per_state_value TEXT -- example: ['NULL', '18.8'],
	awards_per_natl_value REAL -- example: ['21.5', '22.5'],
	exp_award_state_value TEXT -- example: ['NULL', '75743'],
	exp_award_natl_value INTEGER -- example: ['66436', '101725'],
	state_appr_value TEXT -- example: ['NULL', '290.68'],
	state_appr_rank TEXT -- example: ['NULL', '11'],
	grad_rate_rank TEXT -- example: ['23', '18'],
	awards_per_rank TEXT -- example: ['42', 'NULL'],
	PRIMARY KEY (stateid, level, control), 
	CONSTRAINT fk_state_sector_details_institution_details FOREIGN KEY(state) REFERENCES institution_details (state)
)


CREATE TABLE state_sector_grads (
	stateid INTEGER -- example: ['2', '1'],
	state TEXT -- example: ['Alaska', 'Alabama'],
	state_abbr TEXT -- example: ['AL', 'AK'],
	control TEXT -- example: ['Private for-profit', 'Private not-for-profit'],
	level TEXT -- example: ['2-year', '4-year'],
	year INTEGER -- example: ['2012', '2011'],
	gender TEXT -- example: ['B', 'F'],
	race TEXT -- example: ['A', 'Ai'],
	cohort TEXT -- example: ['4y bach', '4y other'],
	grad_cohort TEXT -- example: ['0', '1'],
	grad_100 TEXT -- example: ['0', '2'],
	grad_150 TEXT -- example: ['0', '3'],
	grad_100_rate TEXT -- example: ['0', 'NULL'],
	grad_150_rate TEXT -- example: ['0', 'NULL'],
	grad_cohort_ct INTEGER -- example: ['9', '16'],
	CONSTRAINT fk_state_sector_grads_institution_details FOREIGN KEY(state) REFERENCES institution_details (state),
	CONSTRAINT fk_state_sector_grads_state_sector_details FOREIGN KEY(stateid) REFERENCES state_sector_details (stateid)
)

Question: Among the institutes in the state of Alabama whose percent rank for median SAT value within sector is 77, how many of them have over 500 graduates in total in 2011?
Evidence: percent rank for median SAT value within sector refers to med_sat_percentile; over 500 graduates refers to grad_cohort > 500; in 2011 refers to year = 2011;

SQL:
SELECT COUNT(DISTINCT T1.chronname) FROM institution_details AS T1 INNER JOIN institution_grads AS T2 ON T2.unitid = T1.unitid WHERE T1.state = 'Alabama' AND T1.med_sat_percentile = '100' AND T2.year = 2011 AND T2.grad_cohort > 500