I am running a simple query in BigQuery.

```
SELECT
        p.title,
        p.id,
        SUM(view) Views,
        CAST(EXTRACT(DATE from pv.data_tstamp) as string) dateInserted
    FROM  products  p
    LEFT JOIN  productViews  pv
        ON p.sku=pv.sku WHERE
        pv.data_tstamp >= TIMESTAMP('2022-06-20 00:00:00') AND
        pv.data_tstamp  <= TIMESTAMP('2022-06-29 00:00:00') 
        GROUP BY p.title, p.id,
        CAST(EXTRACT(DATE from pv.data_tstamp) as string) order by p.Id

```

I am getting an error:

SELECT list expression references pv.data\_tstamp which is neither grouped nor aggregated at [5:28]

pv.data\_stamp is grouped by as can be seen in the syntax.

if i remove `order by p.id` It works fine, but I need the query to sort the result by Id.