Skip to Content
Menu
This question has been flagged
1 Reply
2153 Views

Query :

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


Example Error

The SQL query is not valid:
column c.parent_state does not exist
LINE 11: c.name = 'Expenses' AND c.parent_state ='Posted'
^
HINT: Perhaps you meant to reference the column "a.parent_state".


So ,  I  want  to  show  query with  status  = Posted 

Avatar
Discard
Best Answer

Hi Hendy,

I have just changed the referencing name of models for easy understanding

select aml.analytic_account_id as x_analytic_account_id, SUM(aml.debit - aml.credit) as x_expense
from account_move_line as aml
left join account_account as aa on aml.account_id = aa.id
left join account_account_type as aat on aa.user_type_id = aat.id
where aat.name = 'Expenses' and aml.parent_state ='posted'
group by
aml.analytic_account_id

parent_state field is in account_move_line  and  not  in  account_account_type,  you  were  calling  it  wrongly,

Hope  it  helps,

Thanks


Avatar
Discard
Author

Thanks !

Related Posts Replies Views Activity
0
Oct 24
97
1
Feb 23
1178
1
Nov 22
1964
1
Oct 21
1852
3
Dec 18
4519