Dludora/Bird-minidev-sqlserver-oracle huggingface dataset:
Database: thrombosis_prediction

Question: The oldest SJS patient's medical laboratory work was completed on what date, and what age was the patient when they initially arrived at the hospital?
Evidence: The larger the birthday value, the younger the person is, and vice versa; 'SJS' refers to diagnosis; (SUBTRACT(year(`First Date`)), year(Birthday)); age of the patients when they initially arrived at the hospital refers to year(Birthday)
SQL (SQLite): SELECT T1.Date, STRFTIME('%Y', T2.`First Date`) - STRFTIME('%Y', T2.Birthday),T2.Birthday FROM Laboratory AS T1 INNER JOIN Patient AS T2 ON T1.ID = T2.ID WHERE T2.Diagnosis = 'SJS' AND T2.Birthday IS NOT NULL ORDER BY T2.Birthday ASC LIMIT 1
SQL (SQL Server): SELECT T1.Date, YEAR(T2.[First Date]) - YEAR(T2.Birthday), T2.Birthday FROM Laboratory AS T1 INNER JOIN Patient AS T2 ON T1.ID = T2.ID WHERE T2.Diagnosis = 'SJS' AND T2.Birthday IS NOT NULL ORDER BY T2.Birthday ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
SQL (Oracle): SELECT T1."DATE", SUBSTR(T2."FIRST DATE", 1, 4) - SUBSTR(T2.Birthday, 1, 4), T2.Birthday FROM Laboratory T1 INNER JOIN Patient T2 ON T1.ID = T2.ID WHERE T2.Diagnosis = 'SJS' AND T2.Birthday IS NOT NULL ORDER BY T2.Birthday ASC NULLS FIRST FETCH FIRST 1 ROWS ONLY

Question: What is the ratio of male to female patients among all those with abnormal uric acid counts?
Evidence: male refers to SEX = 'M'; female refers to SEX = 'F'; abnormal uric acid refers to UA < = '8.0' where SEX = 'M', UA < = '6.5' where SEX = 'F'; calculation = DIVIDE(SUM(UA <= '8.0' and SEX = 'M'), SUM(UA <= '6.5 and SEX = 'F'))
SQL (SQLite): SELECT CAST(SUM(CASE WHEN T2.UA <= 8.0 AND T1.SEX = 'M' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN T2.UA <= 6.5 AND T1.SEX = 'F' THEN 1 ELSE 0 END) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID
SQL (SQL Server): SELECT TRY_CAST(SUM(CASE WHEN T2.UA <= 8.0 AND T1.SEX = 'M' THEN 1 ELSE 0 END) AS FLOAT) / SUM(CASE WHEN T2.UA <= 6.5 AND T1.SEX = 'F' THEN 1 ELSE 0 END) AS _agg1 FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID
SQL (Oracle): SELECT CAST(SUM(CASE WHEN T2.UA <= 8.0 AND T1.SEX = 'M' THEN CAST(1 AS BINARY_DOUBLE) ELSE 0.0 END) AS BINARY_DOUBLE) / SUM(CASE WHEN T2.UA <= 6.5 AND T1.SEX = 'F' THEN CAST(1 AS BINARY_DOUBLE) ELSE 0.0 END) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID
Database: thrombosis_prediction

Question: How many underage patients were examined during the course of the three-year period from 1990 to 1993?
Evidence: underage patients refers to year(Birthday) < 18; three-year period from 1990 to 1993 refers to year(`Examination Date`) between '1990' and '1993'
SQL (SQLite): SELECT COUNT(T1.ID) FROM Patient AS T1 INNER JOIN Examination AS T2 ON T1.ID = T2.ID WHERE STRFTIME('%Y', T2.`Examination Date`) BETWEEN '1990' AND '1993' AND STRFTIME('%Y', T2.`Examination Date`) - STRFTIME('%Y', T1.Birthday) < 18
SQL (SQL Server): SELECT COUNT(T1.ID) AS _agg1 FROM Patient AS T1 INNER JOIN Examination AS T2 ON T1.ID = T2.ID WHERE YEAR(T2.[Examination Date]) BETWEEN '1990' AND '1993' AND YEAR(T2.[Examination Date]) - YEAR(T1.Birthday) < 18
SQL (Oracle): SELECT COUNT(T1.ID) FROM Patient T1 INNER JOIN Examination T2 ON T1.ID = T2.ID WHERE SUBSTR(T2."EXAMINATION DATE", 1, 4) BETWEEN '1990' AND '1993' AND SUBSTR(T2."EXAMINATION DATE", 1, 4) - SUBSTR(T1.Birthday, 1, 4) < 18

Question: How old was the patient who had the highest hemoglobin count at the time of the examination, and what is the doctor's diagnosis?
Evidence: How old the patient refers to SUBTRACT(year(`Examination Date`), year(Birthday)); the highest hemoglobin count refers to MAX(HGB)
SQL (SQLite): SELECT STRFTIME('%Y', T2.Date) - STRFTIME('%Y', T1.Birthday), T1.Diagnosis FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID ORDER BY T2.HGB DESC LIMIT 1
SQL (SQL Server): SELECT YEAR(T2.Date) - YEAR(T1.Birthday), T1.Diagnosis FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID ORDER BY T2.HGB DESC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
SQL (Oracle): SELECT SUBSTR(T2."DATE", 1, 4) - SUBSTR(T1.Birthday, 1, 4), T1.Diagnosis FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID ORDER BY T2.HGB DESC NULLS LAST FETCH FIRST 1 ROWS ONLY

Question: For the patient who was diagnosed with SLE on 1994/2/19, what was his/her anti-Cardiolipin antibody concentration status on 1993/11/12?
Evidence: diagnosed with SLE refers to Diagnosis = 'SLE'; 1994/2/19 refers to Description = '1994-02-19'; anti-Cardiolipin refers to aCL IgM; 1993/11/12 refers to Examination Date = '1993/11/12'
SQL (SQLite): SELECT `aCL IgA`, `aCL IgG`, `aCL IgM` FROM Examination WHERE ID IN ( SELECT ID FROM Patient WHERE Diagnosis = 'SLE' AND Description = '1994-02-19' ) AND `Examination Date` = '1993-11-12'
SQL (SQL Server): SELECT [aCL IgA], [aCL IgG], [aCL IgM] FROM Examination WHERE ID IN ( SELECT ID FROM Patient WHERE Diagnosis = 'SLE' AND Description = '1994-02-19' ) AND [Examination Date] = '1993-11-12'
SQL (Oracle): SELECT "ACL IGA", "ACL IGG", "ACL IGM" FROM Examination WHERE ID IN ( SELECT ID FROM Patient WHERE Diagnosis = 'SLE' AND Description = '1994-02-19' ) AND "EXAMINATION DATE" = '1993-11-12'
Database: thrombosis_prediction

Question: For the patient who was born on 1959/2/18, what is the decrease rate for his/her total cholesterol from November to December in 1981?
Evidence: born on 1959/2/18 refers to Birthday = '1959-02-18'; calculation = DIVISION(SUBTRACT(SUM(Birthday = '1959-02-18' and Date like '1981-11-%' THEN `T-CHO`), SUM(Birthday = '1959-02-18' and Date like '1981-12-%' THEN `T-CHO`)), SUM(Birthday = '1959-02-18' and Date like '1981-12-%' THEN `T-CHO`))
SQL (SQLite): SELECT CAST((SUM(CASE WHEN T2.Date LIKE '1981-11-%' THEN T2.`T-CHO` ELSE 0 END) - SUM(CASE WHEN T2.Date LIKE '1981-12-%' THEN T2.`T-CHO` ELSE 0 END)) AS REAL) / SUM(CASE WHEN T2.Date LIKE '1981-12-%' THEN T2.`T-CHO` ELSE 0 END) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.Birthday = '1959-02-18'
SQL (SQL Server): SELECT TRY_CAST((SUM(CASE WHEN T2.Date LIKE '1981-11-%' THEN T2.[T-CHO] ELSE 0 END) - SUM(CASE WHEN T2.Date LIKE '1981-12-%' THEN T2.[T-CHO] ELSE 0 END)) AS FLOAT) / SUM(CASE WHEN T2.Date LIKE '1981-12-%' THEN T2.[T-CHO] ELSE 0 END) AS _agg1 FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.Birthday = '1959-02-18'
SQL (Oracle): SELECT CAST((SUM(CASE WHEN T2."DATE" LIKE '1981-11-%' THEN CAST(T2."T-CHO" AS BINARY_DOUBLE) ELSE 0.0 END) - SUM(CASE WHEN T2."DATE" LIKE '1981-12-%' THEN CAST(T2."T-CHO" AS BINARY_DOUBLE) ELSE 0.0 END)) AS BINARY_DOUBLE) / SUM(CASE WHEN T2."DATE" LIKE '1981-12-%' THEN CAST(T2."T-CHO" AS BINARY_DOUBLE) ELSE 0.0 END) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T1.Birthday = '1959-02-18'

Question: How many patients who were examined between 1987/7/6 and 1996/1/31 had a GPT level greater than 30 and an ALB level less than 4? List them by their ID.
Evidence: examined between 1987/7/6 and 1996/1/31 refers to Date BETWEEN '1987-07-06' AND '1996-01-31'; GPT level greater than 30 refers to GPT > 30; ALB level less than 4 ALB < 4
SQL (SQLite): SELECT DISTINCT ID FROM Laboratory WHERE Date BETWEEN '1987-07-06' AND '1996-01-31' AND GPT > 30 AND ALB < 4
SQL (SQL Server): SELECT DISTINCT ID FROM Laboratory WHERE Date BETWEEN '1987-07-06' AND '1996-01-31' AND GPT > 30 AND ALB < 4
SQL (Oracle): SELECT DISTINCT ID FROM Laboratory WHERE "DATE" BETWEEN '1987-07-06' AND '1996-01-31' AND GPT > 30 AND ALB < 4
Database: thrombosis_prediction

Question: What number of patients with a degree of thrombosis level 2 and ANA pattern of only S, have a level of anti-Cardiolip in antibody (IgM) 20% higher than average?
Evidence: thrombosis level 2 refers to Thrombosis = 2; ANA pattern of only S refers to ANA = 'S'; average anti-Cardiolip in antibody (IgM) refers to AVG(`aCL IgM`); calculation = MULTIPLY(AVG + AVG, 0.2)
SQL (SQLite): SELECT COUNT(*) FROM Examination WHERE Thrombosis = 2 AND `ANA Pattern` = 'S' AND `aCL IgM` > (SELECT AVG(`aCL IgM`) * 1.2 FROM Examination WHERE Thrombosis = 2 AND `ANA Pattern` = 'S')
SQL (SQL Server): SELECT COUNT(*) AS _agg1 FROM Examination WHERE Thrombosis = 2 AND [ANA Pattern] = 'S' AND [aCL IgM] > (SELECT AVG(TRY_CAST([aCL IgM] AS FLOAT)) * 1.2 FROM Examination WHERE Thrombosis = 2 AND [ANA Pattern] = 'S')
SQL (Oracle): SELECT COUNT(*) FROM Examination WHERE Thrombosis = 2 AND "ANA PATTERN" = 'S' AND "ACL IGM" > (SELECT AVG("ACL IGM") * 1.2 FROM Examination WHERE Thrombosis = 2 AND "ANA PATTERN" = 'S')

Question: List all patients who were followed up at the outpatient clinic who underwent a laboratory test in October 1991 and had a total blood bilirubin level within the normal range.
Evidence: followed up at the outpatient clinic refers to Admission = '-'; laboratory test in April 1981 refers to Date like '1991-10%'; blood bilirubin level within the normal range refers to T-BIL < 2.0; 
SQL (SQLite): SELECT DISTINCT T1.ID FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.Admission = '-' AND T2.`T-BIL` < 2.0 AND T2.Date LIKE '1991-10-%'
SQL (SQL Server): SELECT DISTINCT T1.ID FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.Admission = '-' AND T2.[T-BIL] < 2.0 AND T2.Date LIKE '1991-10-%'
SQL (Oracle): SELECT DISTINCT T1.ID FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T1.Admission = '-' AND T2."T-BIL" < 2.0 AND T2."DATE" LIKE '1991-10-%'

Question: What is the average blood albumin level for female patients with a PLT greater than 400 who have been diagnosed with SLE?
Evidence: average blood albumin level refers to AVG(ALB); female refers to SEX = 'F'; PLT greater than 400 refers to PLT > 400; diagnosed with SLE refers to Diagnosis= 'SLE'
SQL (SQLite): SELECT AVG(T2.ALB) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.PLT > 400 AND T1.Diagnosis = 'SLE' AND T1.SEX = 'F'
SQL (SQL Server): SELECT AVG(TRY_CAST(T2.ALB AS FLOAT)) AS _agg1 FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.PLT > 400 AND T1.Diagnosis = 'SLE' AND T1.SEX = 'F'
SQL (Oracle): SELECT AVG(T2.ALB) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2.PLT > 400 AND T1.Diagnosis = 'SLE' AND T1.SEX = 'F'

Question: How many female patients were given an APS diagnosis?
Evidence: female refers to SEX = 'F'; APS diagnosis refers to Diagnosis='APS'
SQL (SQLite): SELECT COUNT(ID) FROM Patient WHERE SEX = 'F' AND Diagnosis = 'APS'
SQL (SQL Server): SELECT COUNT(ID) AS _agg1 FROM Patient WHERE SEX = 'F' AND Diagnosis = 'APS'
SQL (Oracle): SELECT COUNT(ID) FROM Patient WHERE SEX = 'F' AND Diagnosis = 'APS'
Database: thrombosis_prediction

Question: What percentage of patients who were born in 1980 and were diagnosed with RA are women?
Evidence: born in 1980 refers to YEAR(BIRTHDAY) = '1980'; 'RA' refers to Diagnosis='RA' ; women refers to SEX = 'F'; calculation = DIVIDE(SUM(SEX = 'F'), COUNT(SEX)) * 100
SQL (SQLite): SELECT CAST(SUM(CASE WHEN SEX = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(ID) FROM Patient WHERE Diagnosis = 'RA' AND STRFTIME('%Y', Birthday) = '1980'
SQL (SQL Server): SELECT TRY_CAST(SUM(CASE WHEN SEX = 'F' THEN 1 ELSE 0 END) AS FLOAT) * 100 / COUNT(ID) AS _agg1 FROM Patient WHERE Diagnosis = 'RA' AND YEAR(Birthday) = '1980'
SQL (Oracle): SELECT CAST(SUM(CASE WHEN SEX = 'F' THEN CAST(1 AS BINARY_DOUBLE) ELSE 0.0 END) AS BINARY_DOUBLE) * 100 / COUNT(ID) FROM Patient WHERE Diagnosis = 'RA' AND SUBSTR(Birthday, 1, 4) = '1980'

Question: Was the patient with the number 57266's uric acid within a normal range?
Evidence: uric acid within a normal range refers to UA > 8.0 and SEX = 'M'OR UA > 6.5 and SEX = 'F'
SQL (SQLite): SELECT CASE WHEN (T1.SEX = 'F' AND T2.UA > 6.5) OR (T1.SEX = 'M' AND T2.UA > 8.0) THEN true ELSE false END FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.ID = 57266
SQL (SQL Server): SELECT CASE WHEN (T1.SEX = 'F' AND T2.UA > 6.5) OR (T1.SEX = 'M' AND T2.UA > 8.0) THEN 1 ELSE 0 END FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.ID = 57266
SQL (Oracle): SELECT CASE WHEN (T1.SEX = 'F' AND T2.UA > 6.5) OR (T1.SEX = 'M' AND T2.UA > 8.0) THEN 1 ELSE 0 END FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T1.ID = 57266

Question: Provide IDs for male patients with ALT glutamic pylvic transaminase (GPT) that have history of ALT glutamic pylvic transaminase (GPT) exceed the normal range.
Evidence: male refers to SEX = 'M'; ALT glutamic pylvic transaminase (GPT) exceed the normal range refers to GPT > = 60
SQL (SQLite): SELECT DISTINCT T1.ID FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.SEX = 'M' AND T2.GPT >= 60
SQL (SQL Server): SELECT DISTINCT T1.ID FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.SEX = 'M' AND T2.GPT >= 60
SQL (Oracle): SELECT DISTINCT T1.ID FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T1.SEX = 'M' AND T2.GPT >= 60

Question: Please provide the diagnosis of patients with ALT glutamic pylvic transaminase beyond the normal range by ascending order of their date of birth.
Evidence: ALT glutamic pylvic transaminase beyond the normal range refers to GPT > 60; The larger the birthday value, the younger the person is, and vice versa; 
SQL (SQLite): SELECT DISTINCT T1.Diagnosis FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.GPT > 60 ORDER BY T1.Birthday ASC
SQL (SQL Server): SELECT T1.Diagnosis FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.GPT > 60 GROUP BY T1.Diagnosis ORDER BY MIN(T1.Birthday) ASC
SQL (Oracle): SELECT T1.Diagnosis FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2.GPT > 60 GROUP BY T1.Diagnosis ORDER BY MIN(T1.Birthday) ASC
Database: thrombosis_prediction

Question: Provide all ID, sex and birthday of patients whose urea nitrogen (UN) just within the borderline of passing?
Evidence: urea nitrogen (UN) just within the borderline of passing refers to UN = 29; 
SQL (SQLite): SELECT DISTINCT T1.ID, T1.SEX, T1.Birthday FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.UN = 29
SQL (SQL Server): SELECT DISTINCT T1.ID, T1.SEX, T1.Birthday FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.UN = 29
SQL (Oracle): SELECT DISTINCT T1.ID, T1.SEX, T1.Birthday FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2.UN = 29

Question: List and group all patients by sex for total bilirubin (T-BIL) level not within the normal range.
Evidence: List refers to GROUP_CONCAT(DISTINCT ID); total bilirubin (T-BIL) not within normal range refers to T-BIL > = 2.0
SQL (SQLite): SELECT T1.ID,T1.SEX FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.`T-BIL` >= 2.0 GROUP BY T1.SEX,T1.ID
SQL (SQL Server): SELECT T1.ID, T1.SEX FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.[T-BIL] >= 2.0 GROUP BY T1.SEX,T1.ID
SQL (Oracle): SELECT T1.ID, T1.SEX FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2."T-BIL" >= 2.0 GROUP BY T1.SEX,T1.ID

Question: What is the average age of the male patient with high cholesterol?
Evidence: average age = DIVIDE(SUM(SUBTRACT(YEAR(NOW()), YEAR(birthday))), COUNT(ID)); male patient refers to sex = 'M'; high cholesterol refers to `T-CHO` > = 250;
SQL (SQLite): SELECT AVG(STRFTIME('%Y', date('NOW')) - STRFTIME('%Y', T1.Birthday)) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.`T-CHO` >= 250 AND T1.SEX = 'M'
SQL (SQL Server): SELECT AVG(TRY_CAST(YEAR(CONVERT(DATE, GETDATE())) - YEAR(T1.Birthday) AS FLOAT)) AS _agg1 FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.[T-CHO] >= 250 AND T1.SEX = 'M'
SQL (Oracle): SELECT AVG(TO_CHAR(CURRENT_DATE, 'YYYY') - SUBSTR(T1.Birthday, 1, 4)) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2."T-CHO" >= 250 AND T1.SEX = 'M'

Question: For all patients with triglyceride (TG) level beyond the normal range, how many are age more than 50 years?
Evidence: triglyceride (TG) level beyond the normal range refers to TG > = 200; more than 50 years of age = SUBTRACT(year(current_timestamp), year(Birthday)) > 50; Should consider DISTINCT in the final result;
SQL (SQLite): SELECT COUNT(DISTINCT T1.ID) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.TG >= 200 AND STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.Birthday) > 50
SQL (SQL Server): SELECT COUNT(DISTINCT T1.ID) AS _agg1 FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.TG >= 200 AND YEAR(CURRENT_TIMESTAMP) - YEAR(T1.Birthday) > 50
SQL (Oracle): SELECT COUNT(DISTINCT T1.ID) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2.TG >= 200 AND TO_CHAR(CURRENT_TIMESTAMP, 'YYYY') - SUBSTR(T1.Birthday, 1, 4) > 50
Database: thrombosis_prediction

Question: For patient born between 1936-1956, how many male patients have creatinine phosphokinase beyond the normal range?
Evidence: born between 1936-1956 refers to year(Birthday) BETWEEN '1936' AND '1956'; male patients refers to sex = 'M'; creatinine phosphokinase beyond the normal range refers to CPK > = 250; Should consider DISTINCT in the final result;
SQL (SQLite): SELECT COUNT(DISTINCT T1.ID) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE STRFTIME('%Y', T1.Birthday) BETWEEN '1936' AND '1956' AND T1.SEX = 'M' AND T2.CPK >= 250
SQL (SQL Server): SELECT COUNT(DISTINCT T1.ID) AS _agg1 FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE YEAR(T1.Birthday) BETWEEN '1936' AND '1956' AND T1.SEX = 'M' AND T2.CPK >= 250
SQL (Oracle): SELECT COUNT(DISTINCT T1.ID) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE SUBSTR(T1.Birthday, 1, 4) BETWEEN '1936' AND '1956' AND T1.SEX = 'M' AND T2.CPK >= 250

Question: Provide ID, sex and age of patient who has blood glucose (GLU) not within normal range but with total cholesterol(T-CHO) within normal range.
Evidence: age = SUBTRACT(year(current_timestamp), year(Birthday)); blood glucose (GLU) not within normal range refers to GLU > = 180; total cholesterol(T-CHO) within normal range refers to `T-CHO` < 250; 
SQL (SQLite): SELECT DISTINCT T1.ID, T1.SEX , STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.Birthday) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.GLU >= 180 AND T2.`T-CHO` < 250
SQL (SQL Server): SELECT DISTINCT T1.ID, T1.SEX, YEAR(CURRENT_TIMESTAMP) - YEAR(T1.Birthday) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.GLU >= 180 AND T2.[T-CHO] < 250
SQL (Oracle): SELECT DISTINCT T1.ID, T1.SEX, TO_CHAR(CURRENT_TIMESTAMP, 'YYYY') - SUBSTR(T1.Birthday, 1, 4) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2.GLU >= 180 AND T2."T-CHO" < 250

Question: What are the patient's diagnosis for those who has lower red blood blood cell? State their ID and age.
Evidence: patient's diagnosis refers to Diagnosis; lower red blood cell refers to RBC < 3.5; age = SUBTRACT(year(current_timestamp), year(Birthday)); 
SQL (SQLite): SELECT DISTINCT T1.Diagnosis, T1.ID , STRFTIME('%Y', CURRENT_TIMESTAMP) -STRFTIME('%Y', T1.Birthday) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.RBC < 3.5
SQL (SQL Server): SELECT DISTINCT T1.Diagnosis, T1.ID, YEAR(CURRENT_TIMESTAMP) -YEAR(T1.Birthday) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T2.RBC < 3.5
SQL (Oracle): SELECT DISTINCT T1.Diagnosis, T1.ID, TO_CHAR(CURRENT_TIMESTAMP, 'YYYY') -SUBSTR(T1.Birthday, 1, 4) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T2.RBC < 3.5
Database: thrombosis_prediction

Question: Among the patients who were diagnosed with SLE, who is the oldest with normal hemoglobin level. Provide the ID and sex.
Evidence: diagnosed with SLE refers to Diagnosis = 'SLE'; The larger the birthday value, the younger the person is, and vice versa; normal hemoglobin level refers to 10 < HGB < 17;
SQL (SQLite): SELECT T1.ID, T1.SEX FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.Diagnosis = 'SLE' AND T2.HGB > 10 AND T2.HGB < 17 ORDER BY T1.Birthday ASC LIMIT 1
SQL (SQL Server): SELECT T1.ID, T1.SEX FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.Diagnosis = 'SLE' AND T2.HGB > 10 AND T2.HGB < 17 ORDER BY T1.Birthday ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY
SQL (Oracle): SELECT T1.ID, T1.SEX FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T1.Diagnosis = 'SLE' AND T2.HGB > 10 AND T2.HGB < 17 ORDER BY T1.Birthday ASC NULLS FIRST FETCH FIRST 1 ROWS ONLY

Question: Name the ID and age of patient with two or more laboratory examinations which show their hematoclit level exceeded the normal range.
Evidence: age = SUBTRACT(year(current_timestamp), year(Birthday)); patient with two or more laboratory examinations refers to COUNT(ID) > 2; hematoclit level exceeded the normal range refers to HCT > = 52;
SQL (SQLite): SELECT DISTINCT T1.ID, STRFTIME('%Y', CURRENT_TIMESTAMP) - STRFTIME('%Y', T1.Birthday) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.ID IN ( SELECT ID FROM Laboratory WHERE HCT >= 52 GROUP BY ID HAVING COUNT(ID) >= 2 )
SQL (SQL Server): SELECT DISTINCT T1.ID, YEAR(CURRENT_TIMESTAMP) - YEAR(T1.Birthday) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID WHERE T1.ID IN ( SELECT ID FROM Laboratory WHERE HCT >= 52 GROUP BY ID HAVING COUNT(ID) >= 2 )
SQL (Oracle): SELECT DISTINCT T1.ID, TO_CHAR(CURRENT_TIMESTAMP, 'YYYY') - SUBSTR(T1.Birthday, 1, 4) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID WHERE T1.ID IN ( SELECT ID FROM Laboratory WHERE HCT >= 52 GROUP BY ID HAVING COUNT(ID) >= 2 )

Question: For patients with abnormal platelet level, state the number of patients with lower than normal range. How is it compare to the number of patients with higher than normal range?
Evidence: abnormal platelet level refers to PLT <= 100 or PLT >= 400; platelet level lower than normal range refers to PLT < 100; calculation = SUBTRACT(SUM(PLT < 100), SUM(PLT > 400)); platelet level higher than normal range refers to PLT > 400;
SQL (SQLite): SELECT SUM(CASE WHEN T2.PLT <= 100 THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.PLT >= 400 THEN 1 ELSE 0 END) FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID
SQL (SQL Server): SELECT SUM(CASE WHEN T2.PLT <= 100 THEN 1 ELSE 0 END) - SUM(CASE WHEN T2.PLT >= 400 THEN 1 ELSE 0 END) AS _agg1 FROM Patient AS T1 INNER JOIN Laboratory AS T2 ON T1.ID = T2.ID
SQL (Oracle): SELECT SUM(CASE WHEN T2.PLT <= 100 THEN CAST(1 AS BINARY_DOUBLE) ELSE 0.0 END) - SUM(CASE WHEN T2.PLT >= 400 THEN CAST(1 AS BINARY_DOUBLE) ELSE 0.0 END) FROM Patient T1 INNER JOIN Laboratory T2 ON T1.ID = T2.ID