system: You are a text-to-SQL generator. Given a database schema and a question, reply with a single valid SQLite query that answers it. Output only the SQL on one line, with no explanation and no markdown.

user: Schema:
CREATE TABLE all_prevalences (
  ITEM text PRIMARY KEY,
  POPULATION TYPE text,
  OCCURRENCES integer,
  POPULATION COUNT integer,
  PREVALENCE RATE real,
  PREVALENCE PERCENTAGE real
);
CREATE TABLE patients (
  patient text PRIMARY KEY,
  birthdate date,
  deathdate date,
  ssn text,
  drivers text,
  passport text,
  prefix text,
  first text,
  last text,
  suffix text,
  maiden text,
  marital text,
  race text,
  ethnicity text,
  gender text,
  birthplace text,
  address text
);
CREATE TABLE encounters (
  ID text PRIMARY KEY,
  DATE date,
  PATIENT text,
  CODE integer,
  DESCRIPTION text,
  REASONCODE integer,
  REASONDESCRIPTION text
);
CREATE TABLE allergies (
  START text,
  STOP text,
  PATIENT text PRIMARY KEY,
  ENCOUNTER text PRIMARY KEY,
  CODE integer PRIMARY KEY,
  DESCRIPTION text
);
CREATE TABLE careplans (
  ID text,
  START date,
  STOP date,
  PATIENT text,
  ENCOUNTER text,
  CODE real,
  DESCRIPTION text,
  REASONCODE integer,
  REASONDESCRIPTION text
);
CREATE TABLE conditions (
  START date,
  STOP date,
  PATIENT text,
  ENCOUNTER text,
  CODE integer,
  DESCRIPTION text
);
CREATE TABLE immunizations (
  DATE date PRIMARY KEY,
  PATIENT text PRIMARY KEY,
  ENCOUNTER text PRIMARY KEY,
  CODE integer PRIMARY KEY,
  DESCRIPTION text
);
CREATE TABLE medications (
  START date PRIMARY KEY,
  STOP date,
  PATIENT text PRIMARY KEY,
  ENCOUNTER text PRIMARY KEY,
  CODE integer PRIMARY KEY,
  DESCRIPTION text,
  REASONCODE integer,
  REASONDESCRIPTION text
);
CREATE TABLE observations (
  DATE date,
  PATIENT text,
  ENCOUNTER text,
  CODE text,
  DESCRIPTION text,
  VALUE real,
  UNITS text
);
CREATE TABLE procedures (
  DATE date,
  PATIENT text,
  ENCOUNTER text,
  CODE integer,
  DESCRIPTION text,
  REASONCODE integer,
  REASONDESCRIPTION text
);
CREATE TABLE claims (
  ID text PRIMARY KEY,
  PATIENT text,
  BILLABLEPERIOD date,
  ORGANIZATION text,
  ENCOUNTER text,
  DIAGNOSIS text,
  TOTAL integer
);
-- foreign keys: encounters.PATIENT -> patients.patient; allergies.PATIENT -> patients.patient; allergies.ENCOUNTER -> encounters.ID; careplans.PATIENT -> patients.patient; careplans.ENCOUNTER -> encounters.ID; conditions.DESCRIPTION -> all_prevalences.ITEM; conditions.PATIENT -> patients.patient; conditions.ENCOUNTER -> encounters.ID; immunizations.PATIENT -> patients.patient; immunizations.ENCOUNTER -> encounters.ID; medications.PATIENT -> patients.patient; medications.ENCOUNTER -> encounters.ID; observations.PATIENT -> patients.patient; observations.ENCOUNTER -> encounters.ID; procedures.PATIENT -> patients.patient; procedures.ENCOUNTER -> encounters.ID

Hint: sum(case when t2.DATE-t1.birthdate between 20 and 29 then t2.VALUE else 0 end)/count(case when t2.DATE-t1.birthdate between 20 and 29 then t2.PATIENT else null end)-sum(case when t2.DATE-t1.birthdate between 50 and 59 then t2.VALUE else 0 end)/count(case when t2.DATE-t1.birthdate between 50 and 59 then t2.PATIENT else null end)

Question: What is the difference between average glucose reading for patients in the 20s and 50s?

assistant: SELECT SUM(CASE WHEN ROUND((strftime('%J', T2.DATE) - strftime('%J', T1.birthdate)) / 365) BETWEEN 20 AND 30 THEN T2.VALUE ELSE 0 END) / COUNT(CASE WHEN ROUND((strftime('%J', T2.DATE) - strftime('%J', T1.birthdate)) / 365) BETWEEN 20 AND 30 THEN T2.PATIENT END) - SUM(CASE WHEN ROUND((strftime('%J', T2.DATE) - strftime('%J', T1.birthdate)) / 365) BETWEEN 50 AND 60 THEN T2.VALUE ELSE 0 END) / COUNT(CASE WHEN ROUND((strftime('%J', T2.DATE) - strftime('%J', T1.birthdate)) / 365) BETWEEN 50 AND 60 THEN T2.PATIENT END) AS difference FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Glucose'