Table: municipalities_quebec
Columns: code
type
name
regional_county_municipality
region

Question: What is the code for Saint-Damien in Matawinie with a type p?
SQL: SELECT AVG("code") FROM municipalities_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 municipalities_quebec WHERE "regional_county_municipality" = 'd''autray' AND "code" < 52017