我想要查询以获取Postgres中的用户平均值列表

时间:2018-11-16 11:26:00

标签: sql postgresql

我想从具有用户列表的表中获取平均值列表

不是单一平均值,而是列表

select avg(no_of_interactions) from table name;

我要在其中获取{user1,user2,user3}的平均互动列表

它只给我一个平均值

1 个答案:

答案 0 :(得分:2)

应该是

select <column>, avg(no_of_interactions)
from table <name>
group by <column>;

其中<column>是userName或userId或您要用作分组条件的其他任何内容