When I try to run such query
SELECT time, high, low, avg(value) as value
FROM quotes_eod
WHERE symbol = $4 AND time >= $3 AND time <= $1 AND source= $2
ORDER BY time
I got asyncpg.exceptions.GroupingError: column "quotes_eod.time" must appear in the GROUP BY clause or be used in an aggregate function
.
But when I do
SELECT time, high, low, COALESCE(close, value) as value
FROM quotes_eod
WHERE symbol = $4 AND time >= $3 AND time <= $1 AND source= $2
ORDER BY time
I don’t get any error.
Can’t understand, where the error is?