Forum Moderators: open
Ive this table with 2 rows as an example:
id - name - time - mon - price
4 - n1 - 8 - 350 - 10000
4 - n2 - 5 - 450 - 20000
when i try to query this:
select AVG(time) as time, AVG(mon) as mon, AVG(price) as price from table where id=4
it outputs:
time - mon - price
6.5 - 400 - 15000
and if i edit the query to add "name" which will require adding GROUP BY
select name, AVG(time) as time, AVG(mon) as mon, AVG(price) as price from table where id=4 group by datetime
it outputs:
name - time - mon - price
n1 - 8 - 350 - 10000
n2 - 5 - 450 - 20000
so is there a way to optimize the query and get the average and rest of values in same query result?
or must be 2 queries?
Thanks in advance