Postgresql 按问题分组

Postgresql 按问题分组,postgresql,Postgresql,大家好,我想在我的查询中提出这个问题。使用分组功能的解密功能时会出现这个问题 SELECT decrypt(a.email_address, 'secret', 'aes') AS email_address, decrypt(atx.account_description, 'secret', 'aes') AS account_description, a.account_id, a.account_type_id FROM account_type

大家好,我想在我的查询中提出这个问题。使用分组功能的解密功能时会出现这个问题

SELECT decrypt(a.email_address, 'secret', 'aes') AS email_address, 
       decrypt(atx.account_description, 'secret', 'aes') AS account_description,
       a.account_id, a.account_type_id 
    FROM account_type AS atx 
    INNER JOIN accounts AS a ON atx.account_type_id=a.account_type_id 
    GROUP BY email_address
表字段包括:

Account_type <- table names
account_type_id - INT
account_description - BYTEA

Accounts <- table names
account_id - INT
account_type_id - INT
email_address - BYTEA
我在小组里做错什么了吗?请告诉我


但是,当你在MYSQL上查询类似的内容时,不会遇到任何问题。至于postgres是一种非常严格的方法。很抱歉,我仍然是postgres的新手。这是我第一次在我们的新系统上使用postgres。

像这样更改你的查询

SELECT decrypt(a.email_address, 'secret', 'aes') AS email_address, 
decrypt(atx.account_description, 'secret', 'aes') AS account_description,
a.account_id, a.account_type_id 
FROM account_type AS atx 
INNER JOIN accounts AS a ON atx.account_type_id=a.account_type_id 
GROUP BY email_address,atx.account_description,a.account_id,a.account_type_id

您必须给出哪些列在不带out agg的select列表中。函数列

请重新阅读错误,它准确地告诉您做错了什么。
账户描述
应该在group by或
min
/
max
/等中。您希望
group by
做什么?为什么在那里有
group by
?您不使用任何聚合。您想解决什么问题?@bereal我希望通过分组对电子邮件地址进行排序,不要在每个字段中声明它们,很抱歉,我对postgres还不太了解。在mysql中,这没关系,没有问题。Postgres的方法strict@boyee为什么要对字段进行分组?在查询中不使用任何聚合。postgre行为就是这样做的吗?在MYsql上,它只能通过一个组by完成。我真的需要调用组by上的所有字段吗?Read@boyee
SELECT decrypt(a.email_address, 'secret', 'aes') AS email_address, 
decrypt(atx.account_description, 'secret', 'aes') AS account_description,
a.account_id, a.account_type_id 
FROM account_type AS atx 
INNER JOIN accounts AS a ON atx.account_type_id=a.account_type_id 
GROUP BY email_address,atx.account_description,a.account_id,a.account_type_id