تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
2428 أدوات العرض

SELECT a.analytic_account_id AS x_analytic_account_id, SUM(a.credit - a.debit) AS x_sale FROM account_move_line AS a JOIN account_account AS b ON a.account_id=b.id JOIN account_account_type AS c ON b.user_type_id=c.id WHERE c.name = 'Income' AND a.parent_state ='posted'

Error:

column "a.analytic_account_id" must appear in the GROUP BY clause or be used in an aggregate function LINE 2: a.analytic_account_id AS x_analytic_account_id,

 

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

Add  "GROUP BY a.analytic_account_id" at the end after your "WHERE " condition

SELECT a.analytic_account_id AS x_analytic_account_id, SUM(a.credit - a.debit) AS x_sale
FROM account_move_line AS a
JOIN account_account AS b ON a.account_id = b.id\\\
JOIN account_account_type AS c ON b.user_type_id = c.id
WHERE c.name = 'Income' AND a.parent_state ='posted'
GROUP BY a.analytic_account_id

In  newer  versions  of  pgadmin  using postgresql , every column which you are viewing need to be in group by clause

Thanks

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أكتوبر 21
1691
1
أبريل 24
1293
1
أبريل 24
1565
0
سبتمبر 23
5754
1
نوفمبر 22
4255