CREATE TABLE "list_of_municipalities_in_quebec" (
  "code" real,
  "type" text,
  "name" text,
  "regional_county_municipality" text,
  "region" real
);

Question: What is the code for Saint-Damien in Matawinie with a type p?
SQL: SELECT AVG("code") FROM "list_of_municipalities_in_quebec" WHERE "regional_county_municipality"='matawinie' AND "type"='p' AND "name"='saint-damien';

Question: What is the name for the regional county municipality of d'autray and a code less than 52017?
SQL: SELECT "name" FROM "list_of_municipalities_in_quebec" WHERE "regional_county_municipality"='d''autray' AND "code"<52017;