【发布时间】:2021-11-17 21:18:18
【问题描述】:
我在MySql 数据库中执行了以下 SQL 语句,它成功运行
cursor.execute("""SELECT COUNT(*), `deleted` FROM `tweets` WHERE `id` = %s""", (tweet['id'],))
postgres database 中的等价物是什么?
尝试以下
cursor.execute("""SELECT COUNT(*), deleted FROM tweets WHERE id = %s""", (tweet['id'],))
因错误而失败
ERROR: ERROR: column "tweets.deleted" must appear in the GROUP BY clause or be used in an aggregate function
我不确定应该在哪里添加GROUP BY 子句。
任何帮助将不胜感激。
【问题讨论】:
标签: mysql sql postgresql psycopg2