instruction: Calculate the total number of patients admitted before 2123, who had a lab test for clinical chemistry.
response: SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2123" AND lab."CATEGORY" = "Chemistry"