CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)

calculate the maximum age of patients who had hyperglycemia primary disease and were hospitalized for 3 days.
SELECT MAX(demographic.age) FROM demographic WHERE demographic.diagnosis = "HYPERGLYCEMIA" AND demographic.days_stay = "3"
SELECT MAX("demographic"."age") FROM "demographic" WHERE "3" = "demographic"."days_stay" AND "HYPERGLYCEMIA" = "demographic"."diagnosis"