Search code examples
sqlsubquery

Why do I get error Expected end of input but got keyword SELECT?


What I do to get this query right?

Query with error message

I tried to create a subquery using the SELECT clause and I get an error:

Syntax error: Expected end of input but got keyword SELECT at [5:3]


Solution

  • In your query you are missing the group by clause before the FROM.

    select ...,
      COUNT(Orders.order_id) as number_of_orders,
      (select ... group by orders.order_id)
    FROM `..`