i try to Something like this query
Select node.weight * count(ans.cn_gender) as count, ans.cn_gender , poll.pollname
From report.cm_marital_satisfaction ans Join
poll_management.POLLES poll
on ans.cn_pollId = poll.id Join
poll_management.POSITIONS node
on ans.cn_positionId = node.id
Where ans.cn_pollId in (113)
group by ans.cn_gender, poll.pollname
but i have error : ERROR: column "node.weight" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: Select node.weight * count(ans.cn_gender) as count, ans.cn_g... ^ ********** Error **********
ERROR: column "node.weight" must appear in the GROUP BY clause or be used in an aggregate function SQL state: 42803 Character: 8
but I do not want use node.weight in GROUP BY please help me
Use sum()
instead of count()
:
Select sum(node.weight) as count, ans.cn_gender, poll.pollname
From report.cm_marital_satisfaction ans Join
poll_management.POLLES poll
on ans.cn_pollId = poll.id Join
poll_management.POSITIONS node
on ans.cn_positionId = node.id
Where ans.cn_pollId in (113)
group by ans.cn_gender, poll.pollname