WHAT IS THE LOWEST AVERAGE FINISH FOR 40TH POSITION, WITH A TOP 5 LARGER THAN 0?
CREATE TABLE "nascar_sprint_cup_series" (
  "year" text,
  "starts" real,
  "wins" real,
  "top_5" real,
  "top_10" real,
  "poles" real,
  "avg_start" real,
  "avg_finish" real,
  "position" text
);
SELECT MIN("avg_finish") FROM "nascar_sprint_cup_series" WHERE "position"='40th' AND "top_5">0;