**Describe the bug**

When creating a funnel with $autocapture and css selector the postgresql query fails.

**To Reproduce**

Create the following funnel:

![Screenshot from 2020-06-24 23-08-13](https://user-images.githubusercontent.com/148820/85622527-a2f7df00-b66f-11ea-8463-c67ff0b54ab8.png)

**Expected behavior**

No crash

**Additional context**

The generated query is here:

```sql
SELECT
  "posthog_person"."id",
  "posthog_person"."created_at",
  "posthog_person"."team_id",
  "posthog_person"."properties",
  "posthog_person"."is_user_id",
  MIN("step_0"."step_ts") as "step_0"
FROM
  (
    SELECT
      "pdi"."person_id",
      MIN("posthog_event"."timestamp") AS "step_ts"
    FROM
      posthog_event
      JOIN posthog_persondistinctid pdi ON pdi.distinct_id = posthog_event.distinct_id
    WHERE
      (
        "posthog_event"."timestamp" >= '2020-06-17T00:00:00+00:00' :: timestamptz
        AND "posthog_event"."event" = '$autocapture'
        AND "posthog_event"."team_id" = 2
        AND EXISTS(
          SELECT
            W0."id"
          FROM
            posthog_event
            JOIN posthog_persondistinctid pdi ON (pdi.distinct_id = posthog_event.distinct_id) W0
          WHERE
            (
              W0."id" = "posthog_event"."id"
              AND W0."elements_hash" IN (
                SELECT
                  V0."hash"
                FROM
                  "posthog_elementgroup" V0
                WHERE
                  (
                    V0."team_id" = 2
                    AND (
                      SELECT
                        U0."order"
                      FROM
                        "posthog_element" U0
                      WHERE
                        (
                          U0."attr_class" @ > ARRAY ['foobar'] :: varchar(200) []
                          AND U0."group_id" = V0."id"
                        )
                      ORDER BY
                        U0."order" ASC
                      LIMIT
                        1
                    ) IS NOT NULL
                  )
              )
            )
        )
      )
    GROUP BY
      "pdi"."person_id"
  ) step_0
  JOIN posthog_person ON posthog_person.id = "step_0".person_id
WHERE
  "step_0".person_id IS NOT NULL
GROUP BY
  "posthog_person"."id",
  "posthog_person"."created_at",
  "posthog_person"."team_id",
  "posthog_person"."properties",
  "posthog_person"."is_user_id"
```

The syntax error is in this subquery:
```sql
          SELECT
            W0."id"
          FROM
            posthog_event
            JOIN posthog_persondistinctid pdi ON (pdi.distinct_id = posthog_event.distinct_id) W0
```

Have not yet dug into what causes the faulty query.
posthog/models/funnel.py
)
            lateral_joins.append(base_body)
            i += 1
        query_footer = QUERY_FOOTER.format(
            step0=steps[0],
            group_by=person_fields
        )
        query = query + sql.SQL(" ").join(lateral_joins) + query_footer
        return query
    def get_steps(self) -> List[Dict[str, Any]]:
        filter = Filter(data=self.filters)
        with connection.cursor() as cursor:
            qstring = self._build_query(self._gen_lateral_bodies(
                team_id=self.team_id,
                filter=filter)).as_string(cursor.connection)
            cursor.execute(qstring)
            people = namedtuplefetchall(cursor)
        steps = []
        person_score: Dict = defaultdict(int)
        for index, funnel_step in enumerate(filter.entities):
            relevant_people = []
            for person in people:
                if getattr(person, "step_{}".format(index)):
                    person_score[person.id] += 1
                    relevant_people.append(person.id)
            steps.append(self._serialize_step(funnel_step, relevant_people))
        if len(steps) > 0:
            for index, _ in enumerate(steps):
                steps[index]["people"] = sorted(steps[index]["people"], key=lambda p: person_score[p], reverse=True)[0:100]
        return steps